28 Oct Tuesday 7:30 Python Practice – 21.10.26.
You could do the following homework using IDLE
Question 1
Make a variable and assign a number to it (any number you like). Then display your variable using print.
Question 2
Modify your variable, either by replacing the old value with a new value, or by adding something to the old value. Display the new value using print.
Question 3
Make another variable and assign a string (some text) to it.
Then display it using print.
Question 4
Make a variable for DaysPerWeek, HoursPerDay, and MinutesPerHour (or make up your own names), and then multiply them together.
Question 5
People are always saying there’s not enough time to get everything done. How many minutes would there be in a week if there were 26 hours in a day? (Hint: Change the HoursPerDay variable.)
Question 6: (Sample Question)
Write a program to solve the following question: Three people ate dinner at a restaurant and want to split the bill. The total is $35.27, and they want to leave a 15 percent tip. How much should each person pay?
Hint: you can create three variables to start:
>>> people = 3
>>> total = 35.27
>>> tip_percent = 0.15
then you could get the result by calculating step-by-step as following:
>>> tip = total * tip_percent >>> final_total = total + tip >>> each = final_total / people >>> print(each)
Question 7:
Write a program to solve the following question: Calculate the area and perimeter of a rectangular room, 12.5 meters by 16.7 meters.
Hint: when you do this homework, you should assign all the numbers to the variable, such as:
>>> width = 12.5 >>> length = 16.7
Question 7:
Write a program to solve the following question: Three people ate dinner at a restaurant and want to split the bill. The total is $35.27, and they want to leave a 15 percent tip. How much should each person pay? (Hint: you can create three variables to start: people = 3, total = 35.27, tip_percent = 0.15)
Question 8
Write a program to convert temperatures from Fahrenheit to Celsius. The formula for that is:
C = 5 / 9 * (F - 32)
Sorry, the comment form is closed at this time.