Question

In: Computer Science

​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...

​​​​Python

  1. Create a new file named compute_cost.py.

  2. Write your name and date in a comment.

  3. Create a variable named base_fee and set the value to 5.5.

  4. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone.

  5. Convert the zone to an integer.

  6. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the value of the zone.

  7. Compute the cost as follows. Be certain to use the and operator:

If the zone is between 1 and 4, the cost is the base_fee times 2.

Else if, the zone is 5 or 6, the cost is the base_fee times 1.755 plus 7.5.

Else if, the zone is 7, 8, or 9, the cost is the base_fee times 3.125 plus 9.5.

Else, the cost is the base_fee times 4.25.

  1. Print out the cost with two decimal places of precision to the Python shell.

  2. Print out the cost with exponential notation with one decimal place of precision to the Python shell.

  3. Test with a zone of 2, 6, and 9.

Solutions

Expert Solution

'''
Name:<name>
Date:08-10-2020
'''
from sense_hat import SenseHat
import math
base_fee=5.5
zone=int(input("Enter Zone"))
sense = SenseHat()
blue = (0, 0, 255)
yellow = (255, 255, 0)
sense.show_message("The Zone is"+zone, text_colour=blue, back_colour=yellow, scroll_speed=0.3)
if(zone>=1 and zone<=4):
    cost=base_fee*2;
elif(zone==5 or zone==6):
    cost=(base_fee*1.755)+7.5
elif(zone>=7 or zone<=9):
    cost=(base_fee*3.125)+9.5
else:
    cost=base_fee*4.25
print("{0:.2f}".format(cost))#print cost with 2 decimal precision
print("{0:.1f}".format(math.exp(cost)))#print cost with exponential notation and 1 decimal precision

Execution output:

Note:I've commented code related to SenseHat due to my compiler restrictions.


Related Solutions

python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt...
Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is 2,...
Python program: Write a program that reads a text file named test_scores.txt to read the name...
Python program: Write a program that reads a text file named test_scores.txt to read the name of the student and his/her scores for 3 tests. The program should display class average for first test (average of scores of test 1) and average (average of 3 tests) for each student. Expected Output: ['John', '25', '26', '27'] ['Michael', '24', '28', '29'] ['Adelle', '23', '24', '20'] [['John', '25', '26', '27'], ['Michael', '24', '28', '29'], ['Adelle', '23', '24', '20']] Class average for test 1...
Create a file named work.sh in your hw5 directory. Give this file read and write permission...
Create a file named work.sh in your hw5 directory. Give this file read and write permission (no execute permissions) for you alone. No other account should have any access privileges to this file. Change the permissions on the work.sh file so you have read and write permissions. Give everybody else, including the group, read permissions only. Give yourself read, write and execute permissions to the file work.sh. Give everyone else, including the group, execute permissions only. Create a directory named...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts...
USING JAVASCRIPT Create a file name dayOfWeek.js and write an arrow function named dayOfWeek that accepts a Date object dateStr and returns a string that is the day of the week in English form (i.e. “Sunday”, “Monday”, etc.). Test your function by creating a date object that is a significant date to you (such as your birthday) and passing that date object to your function. Test your function at least twice with two different dates. Submit the dayOfWeek.js file to...
Name your functions countOnesLoop() and countOnesWhere() and submit your code in a file named countOnes.py. Write...
Name your functions countOnesLoop() and countOnesWhere() and submit your code in a file named countOnes.py. Write a function that consists of a set of loops that run through an array and count the number of ones in it. Do the same thing using the where() function (use info(where) to find out how to use it) (in python)
Problem: Write a Python module (a text file containing valid Python code) named p5.py. This file...
Problem: Write a Python module (a text file containing valid Python code) named p5.py. This file must satisfy the following. Define a function named rinsert. This function will accept two arguments, the first a list of items to be sorted and the second an integer value in the range 0 to the length of the list, minus 1. This function shall insert the element corresponding to the second parameter into the presumably sorted list from position 0 to one less...
Implement a python program in file named tarvel.py. Create an empty dictionary named responses. Implement while...
Implement a python program in file named tarvel.py. Create an empty dictionary named responses. Implement while loop to take in user's name and desired destination for as long as there are user inputs. Prompt user to input yes to continue and no to quit. Prompt for user's name. Receive the name into the program and save it as the value of name variable. Prompt user for their desired vacation destination. Receive response and save it as the value of a...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
2. Add a title comment block to the top of the new Python file using the...
2. Add a title comment block to the top of the new Python file using the following form # A brief description of the project 3. Ask user - to enter the charge for food 4. Ask user - to enter theTip for server ( remember this is a percentage , the input therefore should be decimal. For example, for a 15% tip, 0.15 should be entered) 5. Ask user - to enter the Tax amount ( this is a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT