Create 5 programs
change.py
Create a program, change.py, that has a function that takes 4 arguments that correspond to the number of quarters, dimes, nickels, and pennies, respectively. Calculate the total value of that change, and print "The total value of your change is $x" where x is equal to the total value.
As an information, the below code does not work, I have to use arguments instead of val
Hint
The total value of your change is $0.41
The total value of your change is $8.76
The total value of your change is $1025.75
Please enter the count of each coin type.
def main(): # start a function definition
print("Change Counter") # print a string to the screen
print() # prints a newline to the screen
print("Please enter the count of each coin type.")
quarters = eval(input("Quarters: "))
dimes = eval(input("Dimes: "))
nickels = eval(input("Nickels: "))
pennies = eval(input("Pennies: "))
# multiplication is performed before addition
firsttotal = quarters * .25 + dimes * .10 + nickels * .05 + pennies * .01
total = round(firsttotal,2)
print()
print("The total value of your change is", total)
main()
luke.py
Create a program, luke.py, using the following dictionary:
relations = {'Darth Vader':'father', 'Leia':'sister', 'Han':'brother in law', 'R2D2':'droid', 'Rey':'Padawan', 'Tatooine':'homeworld'}
The program will take one argument, corresponding to one of the relations’ keys. The program will print out the statement:
Luke, I am your x
Where x = the relationship.
For example, if the argument is Leia, it should print ‘Luke, I am your sister’
If the key is ‘Darth Vader’ you should instead print “No, I am your father
max3.py
Create a program, max3.py, that has a function that takes three arguments. The program will then print out the highest of the three values.
mintosec.py
Create a program, mintosec.py, that takes one integer argument representing a number of minutes. The program will convert the argument to the corresponding number of seconds, and print that value out.
temp.py
Create a program, temp.py, that takes in one numeric argument representing a Celsius value. Then, print out the corresponding Fahrenheit value to two decimals in the form:
The temperature is x degrees Fahrenheit.
Where x is the calculated Fahrenheit value
Get Free Quote!
326 Experts Online