Question: Can someone help me with these programming situations. I have been struggling getting them exact. Problem 1. (15pts) Write the python code that prompts the
Can someone help me with these programming situations. I have been struggling getting them exact.




Problem 1. (15pts) Write the python code that prompts the user for two integer values, and displays the results when each of the following arithmetic operators are applied (+,- *, /, //,%, **). All floating-point results should be displayed with three decimal places of accuracy. In addition, all values should be displayed with commas where appropriate. For example, if the user enters the values 5 and 4, the output would be, Please enter the first number: 5 Please enter the second number: 4 -----Problem 1--- 5 + 4 = 9 5 - 4 = 1 5 * 4 = 20 5/ 4 = 1.250 5 // 4 - 1 5 % 4 = 1 5 ** 4 = 625 if the user enters the values 2500 and 5, the output would be Please enter the first number: 2500 Please enter the second number: 5 ------ Problem l--- 2500 + 5 = 2,505 2500 - 5 = 2,495 2500 * 5 = 12,500 2500 / 5 = 500.000 2500 // 5 = 500 2500 X 5 = 0 2500 ** 5 = 97,656,250,000,000,000 Problem 2. (15pts) Re-write Problem 1 but this time prompts the user for two floating-point values, and displays the results when each of the following arithmetic operators are applied (+,-* 1,//,%, **). All floating-point results should be displayed with three decimal places of accuracy. In addition, all values should be displayed with commas where appropriate. For example, if the user enters the values 7.5 and 2, the output would be, --------- Problem 2----- Please enter the first number: 7.5 Please enter the second number: 2 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 7.5 + 2.0 = 9.500 7.5 - 2.0 - 5.500 7.5 * 2.0 = 15.000 7.5 / 2.0 = 3.750 7.5 // 2.0 = 3.000 7.5 % 2.0 = 1.500 7.5 ** 2.0 = 56.250 Problem 4. (50pts) Write a program that helps the Five Star Retro Video to calculate the total charge. Five Star Retro Video rents VHS tapes and DVDs to the same connoisseurs who like to buy LP record albums. The store rents new videos for $3.00 a night and oldies for $2.00 a night. Write a program that the clerks at Five Star Retro Video can use to calculate the total charge for a customer's video rentals. The program should prompt the user for the number of each type of video and total nights and output the total cost with only two decimal points and with commas where appropriate. ---Problem 4---- Please enter how many new videos do you want to rent? 3 Please enter how many old videos do you want to rent? 2 How many nights do you want to keep them? 3 The total cost is $39.00 There should be no space between the $ sign and the value. Another output: ----Problem 4--- Please enter how many new videos do you want to rent? 234 Please enter how many old videos do you want to rent? 500 How many nights do you want to keep them? 2 The total cost is $3,404.00 Python ord() and chr() are built-in functions. They are used to convert a character to an int and vice versa. Python ord() and chr() functions are exactly opposite of each other. Python ord() Python ord() function takes string argument of a single Unicode character and return its integer Unicode code point value. Let's look at some examples of using ord() function. Try the following: x = ord ('A') print (x) print (ord('c')) print (ord ('4')) print (ord ('$')) Python chr() Python chr() function takes integer argument and return the string representing a character at that code point. x = chr (65) print (x) print (chr(99)) print (chr (52)) print (chr (36)) Problem 3. (20pts) Write the python code that prompts the user to enter an upper or lower case letter and displays the corresponding Unicode encoding. Here are two sample outputs for letters 'S' and 'f': -----Problem 3-- Please enter a letter: S The corresponding Unicode encoding for s is 83 ----Problem 3-- Please enter a letter: f The corresponding Unicode encoding for f is 102 if the user enters the values 1525.75 and 10.5, the output would be, ----Problem 2-- Please enter the first number: 1525.75 Please enter the second number: 10.5 EEEEEEEEEEEEEEEEEEE 1525.75 + 10.5 = 1,536.250 1525.75 - 10.5 = 1,515.250 1525.75 * 10.5 = 16,020.375 1525.75 / 10.5 = 145.310 1525.75 // 10.5 = 145.000 1525.75 % 10.5 = 3.250 1525.75 ** 10.5 = 2,670, 394,812,030, 440,991,598,310,905,085,952.000 Add a new line for both problem 1 and 2 to display the result of the exponentiation (**), with exactly two decimal places displayed in scientific notation. Here is a sample output after the addition of scientific notation lines: -------------- Problem 1----- Please enter the first number: 25 Please enter the second number: 3 25 + 3 = 28 25 - 3 = 22 25 + 3 = 75 25 / 3 = 8.333 25 // 3 = 8 25 % 3 = 1 25 ** 3 = 15, 625 25 ** 3 = 1.56e+04 ------- Problem 2--- Please enter the first number: 24.5 Please enter the second number: 2.2 24.5 + 2.2 = 26.700 24.5 - 2.2 = 22.300 24.5 * 2.2 = 53.900 24.5 / 2.2 = 11.136 24.5 // 2.2 = 11.000 24.5 % 2.2 = 0.300 24.5 ** 2.2 = 1, 138.061 24.5 ** 2.2 = 1.14e+03
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
