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)
python Create a file named sales_bonus.py 2. Prompt the user for the amount of sales made,...
python Create a file named sales_bonus.py 2. Prompt the user for the amount of sales made, convert to a float, and assign to sales. 3. Prompt the user for number of days missed, covert to an int, and assign to days_missed 4. If the user have more than 3000 of sales and has missed less than or equal to two days of work, assign bonus to 100. 5.   Else if the user have more than 3000 of sales or has missed...
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...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant...
Create a file named StudentArrayList.java,within the file create a class named StudentArrayList. This class is meant to mimic the ArrayList data structure. It will hold an ordered list of items. This list should have a variable size, meaning an arbitrary number of items may be added to the list. Most importantly this class should implement the interface SimpleArrayList provided. Feel free to add as many other functions and methods as needed to your class to accomplish this task. In other...
Use your IDE (PyCharm) to create a new file named countertop.py. Type in the following lines,...
Use your IDE (PyCharm) to create a new file named countertop.py. Type in the following lines, exactly as they are shown here (including the four spaces before the indented lines of code) and save the file: def countertop(sideLength): """ Compute the area of a square countertop with a missing wedge. The parameter x is the length of one side of the square. """ square = sideLength ** 2 # area of the full square triangle = ((sideLength / 2) **...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT