I'm needing help creating a Python program of the
fallowing:
According to what their should be about 4 functions and 1 main
function to the end. Please run the program all the way.
Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.
CODE
#function to find largest rainfall
def largestRainfall(arr, n):
large = 0
#finding largest rainfall
for i in range(1, n):
if arr[i] > arr[large]:
large = i
#return index of largest rainfall
return large
#function to find smallest rainfall
def smallest(arr, n):
small = 0
#finding smallest rainfall
for i in range(1, n):
if arr[i] < arr[small]:
small = i
#return index of smallest rainfall
return small
#function to find average rainfall
def averageRainfall(arr, n):
total = 0
#calculating total rainfall
for i in range(n):
total = total + arr[i]
#calculating average rainfall
avg = total / n
#returns average
return avg
#function to print classified table
def ClassifyAndDisplay(arr, n, average, month):
print("{:14s}".format("\nMonth") +
"{:14s}".format("Rainfall(mm)") + "Classification")
print("-----------------------------------")
#printing classified table
for i in range(n):
#if rainfall is 20% higher than
average
if(arr[i] > (average + (average
* .2))):
print("{:14s}".format(month[i]) + "{:14s}".format(str(arr[i])) +
"Rainy")
#if rainfall is 25% lower than
average
elif(arr[i] < (average -
(average * .25))):
print("{:14s}".format(month[i]) + "{:14s}".format(str(arr[i])) +
"Dry")
#if near to average
else:
print("{:14s}".format(month[i]) + "{:14s}".format(str(arr[i])) +
"Average")
#main function
def main():
#list of months
month = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October',
'November', 'December']
list1 = []
#opening rainfall.txt
f = open("rainfall.txt", "r")
#appending rainfall data to list
for line in f:
list1.append(int(line))
#calling averageRainfall
average = averageRainfall(list1, 12)
#printing average rainfall
print("Average monthly rainfall was " + str(average) +
" mm")
#calling largestRainfall
Ans = largestRainfall(list1, 12)
#printing largest rainfall
print(month[Ans] + " has the highest rainfall (" +
str(list1[Ans]) + " mm)")
#calling smallest
Ans = smallest(list1, 12)
#printing smallest rainfall
print(month[Ans] + " has the lowest rainfall (" +
str(list1[Ans]) + " mm)")
#calling ClassifyAndDisplay
ClassifyAndDisplay(list1, 12, average, month)
#calling main
main()
OUTPUT
CODE SCREEN SHOT
I'm needing help creating a Python program of the fallowing: According to what their should be...
I need help in creating an MP3 Player GUI program in python. It should show information on the file that is playing like its's name,length,amount of play time in minutes and seconds and a feature that allows to create a playlist
For Python-3 I need help with First creating a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots. Write a python program that 1. Puts this as the first line... import os 2. Creates an empty list 3. Defines main() function that performs the tasks listed below when called. 4. Put these two lines at the top of the main function... if os.path.exists("costlist.txt"): os.remove("costlist.txt") Note: This removes the "costlist.txt" file, if it exists. 5....
I'm needing help writing a program that reads a list of scores from a .txt file then drops the lowest. Instructions are below. Then use the "low score drop" algorithm in a program to read and process an indeterminate number of floating-point scores from a file. The program should then display the result (the lowest score in the file), with two digits after the decimal. There is no restriction on these values; they might be negative or positive, and the...
Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...
This program is in python and thanks fro whoever help me. In this program, you will build an English to Hmong translator program. Hmong is a language widely spoken by most Southeast Asian living in the twin cities. The program lets the user type in a sentence in English and then translate it to a Hmong sentence. The program does not care about grammar or punctuation marks. That means your program should remove punctuation marks from the English words before...
Write a Python Program that displays repeatedly a menu as shown in the sample run below. The user will enter 1, 2, 3, 4 or 5 for choosing addition, substation, multiplication, division or exit respectively. Then the user will be asked to enter the two numbers and the result for the operation selected will be displayed. After an operation is finished and output is displayed the menu is redisplayed, you may choose another operation or enter 5 to exit the...
Help with Python code. Right now I'm creating a code in Python to create a GUI. Here's my code: #All modules are built into Python so there is no need for any installation import tkinter from tkinter import Label from tkinter import Entry def calculatewages(): hours=float(nhours.get()) nsal=float(nwage.get()) wage=nsal*hours labelresult=Label(myGUI,text="Weekly Pay: $ %.2f" % wage).grid(row=7,column=2) return Tk = tkinter.Tk() myGUI=Tk myGUI.geometry('400x200+100+200') myGUI.title('Pay Calculator') nwage=float() nhours=float() label1=Label(myGUI,text='Enter the number of hours worked for the week').grid(row=1, column=0) label2=Label(myGUI,text='Enter the pay rate').grid(row=2, column=0)...
Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...
please help, language is python You’re creating a secret code to share with your friends such that every word should be written with the second and last letters swapped. Write a function called encode that receives a string (input) and prints out another string with the second and last letters swapped. Example function calls: encode(secret) # should print “the code for secret is stcree” encode(city) # should print “the code for city is cyti”
While using python programming. If the program is broken into smaller modules where does execution begin?Can you Please explain? I think it is not a good idea to write a large program with only one function because creating a large program can have benefits on using modular programming than less code. Modular programming is the process of subdividing a computer program into separate sub-programs. A module is a separate software component. It can often be used in a variety of...