Homework 3 - Loops
Due Date: September 28, 2023
Due by 11:59 pm on the due date.
Problems
- Write a program that prints to the screen a table of Fahrenheit temperatures and their Celsius equivalents, such as:
Fahrenheit Celsius 0 -17.8 20 -6.7 40 4.4 ... ... 280 137.8 300 148.9 for
loop, and (2) using awhile
loop. - Write a program that prompts the user to enter a positive integer, say \(N\), and then prints to the screen the value of the polynomial \(f(x) = x^2 + 7x -4\) at the values \(x = 1, 2, \ldots, N\). Specifically, if the user inputs \(N=10\) then your program would print to the screen the following lines of strings exactly as shown below:
1^2 + 7*1 - 4 = 4
2^2 + 7*2 - 4 = 14
3^2 + 7*3 - 4 = 26
4^2 + 7*4 - 4 = 40
5^2 + 7*5 - 4 = 56
6^2 + 7*6 - 4 = 74
7^2 + 7*7 - 4 = 94
8^2 + 7*8 - 4 = 116
9^2 + 7*9 - 4 = 140
10^2 + 7*10 - 4 = 166 Recall that \[ n! = 1\cdot 2 \cdot 3 \cdots (n-1)\cdot n.\] For example, \[5!=1\cdot 2\cdot 3 \cdot 4\cdot 5 = 120.\] Write a program that prompts the user for a positive integer, say \(n\), and prints the output value \(n!\). Your program should use a
for
loop to compute \(n!\). If the user enters an integer less than 1 then your program should print the message "Please enter an integer greater than 0" and then ask the user for a new input. If the user enters an integer greater than 1000 then your program should print the message "Please enter an integer not greater than 1000" and then ask the user for a new input. Your program should continue to ask for a valid integer if the user inputs an integer outside the range [1, 1000].- Watch this video for instructions. You will need to import the
random
module to generate a random number like so:from random import randint
spin_value = randint(20, 40) - Incorporate any suggestions to your solution to Problem 7 from Homework 2. Then, add to your reservation system the ability for the customer to make as many flight reservations as desired. Thus, after making a reservation, you could ask the customer:
If the customer chooses yes, then present to the customer the same flight options, otherwise tell the customer to have their payment method ready to make the purchases. In addition to the travel time for each flight, include the cost of each flight and when the user chooses to checkout make sure to tell them the total of the purchases. Again, be creative!Would you like to make another reservation?