I have these homework questions for a summer course I am taking and I am honestly lost on where to begin with answering them because I have no idea on what to do. So if anyone can help me please help me.
-
If you were writing a program where the user was supposed to input their scores from the last several tracks meets, and the program would calculate and output some statistics, what try except blocks might you want to include in this program?
-
Some Python experts suggest that almost every part of a program be in a function, and the main program is limited to calling these functions. What advantages and disadvantages do you see to this approach?
-
Identify one syntax error and one logic error in this function, which is supposed to tell the user how many vans will be needed to transport the debate team:
def vans_needed(): students = int(input("How many students are there?") vans = students / 14 print("You will need", vans, "vans.")
-
In what situations might you need to use a function that calls another function?
-
Consider the following program:
boxes = int(input("How many boxes do you have?")) sweaters = int(input("How many sweaters do you have?")) sweatersPerBox = sweaters/boxes print("You need to put", sweatersPerBox, "sweaters in each box.")
There is certain user input that will cause this program to crash. Can you think of two different ways that you can prevent that from happening? -
Consider the following program:
def totalCost(a, b): cost = 1.08 * (a + b) totalCost(38, 14) print("The cost will be", cost)
The function totalCost adds two prices and then calculates the sales tax (by multiplying by 1.08). The main program prints out the total cost. Does this program accomplish that successfully? Why or why not? If not, how should it be changed? -
Consider the following program:
def sum(a, b): total = a + b print(total) sum(total, a) sum(1, 0)
What problem does it have? How can it be fixed?
Ive had ideas on what I would do but I keep getting them wrong so I dicided on getting on experts opinion on these questions.
Piper_J is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.