Calculates a new value based on an original value

Assignment Help Python Programming
Reference no: EM132620824

Practical - Coding

Solutions for these checkpoint questions are provided as worked solution demonstration videos.

Do the numbered questions in a file called programs.py

Input, Processing, Output

1. Write a program that calculates a new value based on an original value and a (percentage-like) increase or decrease.
Example:
• Original: 100, Change: 0.05, Result: 105
• Original: 50.5, Change: -0.1, Result: 45.45

Decision Structures

2. Ask the user for the time of day (0-23 hours) and if they are coming or going.
Then print a statement about their situation like:
It is before noon and you are coming. Hi!
It is after noon and you are going. Bye!
Note:
Remember the DRY (Don't Repeat Yourself) principle?
The intention with this exercise is for you to see that what the user inputs for these 2 questions are unrelated.
You can store the results to be printed in string variables and then print a SINGLE output using those variables.
You do NOT want to handle this with 4 separate print statements; one for each possible outcome.
Why not?
Because in ALL cases, you print one thing. So, only print once... but customise what you print based on the 2 user inputs.
Also, there's no such thing as "noon" :) As soon as you hit 12, it's "after noon".

3. Coffee orders made simple.
• Ask the user for white or black coffee
• Ask for their chosen size: small, medium or large
• Then print the cost: For Black, Small = $3, Medium = $4, Large = $5. White coffee costs $1 more per size.
• If a user makes a mistake with either part of their order, just pick the more expensive option in each case :)
E.g. a purple small coffee would cost $4 and a black tiny coffee would cost $5.
(This can be done by thinking about the default case for each user input.)
Note: You can use the string methods .upper() or .lower() to make your string comparisons case insensitive, e.g.
string =input("Prompt: ").lower()
if string =="string":
print("It matches without capitals")

Repetition Structures
4. Add error-checking to the coffee order program so you repeat until you get valid inputs.
5. Write a program to ask the user for a low value and a high value, then print all of the integers between those values inclusive and show the total of those numbers.
Example, if the inputs were 10 and 20, you would print:
10 11 12 13 14 15 16 17 18 19 20 totals: 165

All Together Now
File: happy_products.py
Happy Products is an exciting new company that provides happy products to people who use their awesome new software...
But it's up to you to write this awesome new software.
They want a menu with the options:
• Instructions
• Calculate
• Quit
When you calculate, you are asked how many products you want to buy and at what price (see how exciting this is?).
If you buy 0-5 items, they're full price, over 5 items and each one is 10% off!
Examples:
• 5 x $10 products = $50
• 6 x $50 products = $270
Under 0 items is invalid and so are negative/$0 products, so keep prompting the user until they enter valid inputs.
The menu should also handle invalid choices by printing "Invalid choice".
The instructions are:
Enter the number of products you want to buy and your chosen price. If you buy 0-5 items, they're full price, over 5 items and each one is 10% off!

Deliverables
This section summarises the expectations for marking in this practical.
• programs.py with all of the numbered checkpoint questions:
1. Percentage program (I, P, O)
2. Time of day (Decisions)
3. Coffee orders (Decisions)
4. Coffee order error-checking (Repetitions)
5. Low-high printing (Repetitions)
• happy_products.py (The All Together Now question)

Reference no: EM132620824

Questions Cloud

Journal transactions to record the lease : How do prepare the amortization table for 2018 and 2019 and journal these transactions to record the lease, the first lease payment
Coronary vessels that supply the right side of the heart : List the coronary vessels that supply the right side of the heart.
Difference between qualitative data and quantitative data : What is the difference between qualitative data and quantitative data? Provide four different variables that you could test in your plant growth experiment.
Identify costs per unit to identify the prime cost : Question - Use the following costs per unit to identify costs per unit to identify the prime cost, total production cost, and total cost for a product
Calculates a new value based on an original value : Write a program that calculates a new value based on an original value and a (percentage-like) increase or decrease - You can store the results to be printed
What is journal entry to record the transaction on january : What is the carrying amount of the note payable on December 31, 20R? What is the journal entry to record the transaction on Jan. 1, 20Q?
Evaluate all seven steps of ethical decision-making model : Evaluate all seven steps of the ethical decision-making model. Analyze how each step can be applied to your chosen dilemma.
Estimating percentage of each dish that is covered : Bacterial growth is measured by estimating the percentage of each dish that is covered by bacteria at the end of a 3-day growth period.
Compute the business-wide overhead absorption rate : Estimates of direct labor hours for each department are 5,000 7,000 and 10,000 hours respectively. Compute the business-wide overhead absorption rate

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd