Question

NOTE:- PLEASE USE THE INSTRUCTION ACCORDING TO "CHAPTER 3" OF "STARTING OUT WITH PYTHON 4TH EDITION"...

NOTE:- PLEASE USE THE INSTRUCTION ACCORDING TO "CHAPTER 3" OF "STARTING OUT WITH PYTHON 4TH EDITION"

PROGRAM 3_1:-

Write a program that determines the cost of online order of T-shirts. T-shirts are priced at $12.99 each, but discounts are applied for quantities as follows:

- 12 or more shirts earn a 30% discount and free shipping

- 6-11 shirts earn a 20% discount

- and 3-5 shirts earn a 10% discount

- 1 or 2 shirts, no discounts

Prompt the user to enter the quantity desired and then calculate the cost of the order, including shipping if applicable. Ignore tax. Shipping costs are $8.99. The charges should be displayed in currency format with the $ sign right up against the first digit.

PROGRAM 3_2:-

Write a program named program33.py that prompts the user to enter an odd number between 30 and 80 and then responds to user input. Code the program to respond to all four possible responses as shown in the sample outputs below.

Sample Outputs (3)
Enter an odd number between 30 and 80 89
That was odd but out of required range
===========================================

Enter an odd number between 30 and 80 50
That was in range but it was even, not odd
===========================================
Enter an odd number between 30 and 80 100
That input was out of range and not odd

Please help me with this python question?
============================================
Enter an odd number between 30 and 80 57
Good input

Homework Answers

Answer #1

Program 3_1 -

Here is the code, with comments for clear understanding (round has been used while printing so that the answer is printed up to two decimal places)


price = 12.99 # declare the price variable
shipping = 8.99 # declare the shipping variable
n = int(input("Enter quantity of T-Shirts: ")) # ask the quantity from user
total_cost = n*12.99 # calculate total cost by multiplying quantity by price

if n>=12: # if number of t-shirts are more than 12
total_cost = total_cost - 0.3*total_cost # calculate the discounted price
# no shipping charges here
  
elif n>=6 and n<=11: # if number of t-shirts are in a range of 6-11
total_cost = total_cost - total_cost*0.2 # calculate the discounted price
total_cost = total_cost + 8.99 # add the shipping charges
  
elif n>=3 and n<=5: # if number of t-shirts are in a range of 3-5
total_cost = total_cost - total_cost*0.1 # calculate the discounted price
total_cost = total_cost + 8.99 # add the shipping charges
  
elif n==1 or n==2: # if number of t-shirts is 1 or 2
# no discount in this case
total_cost = total_cost + 8.99 # add the shipping charges
  
print("Total cost is: $",round(total_cost,2))

  

Code Screenshot -

Output Screenshot -

Program 3_2 -

Here is the code, with comments for clear understanding -

# % sign is used to check the remainder of a number which can tell if a
# number is even or odd. For example, 6 is an even number and 6%2 gives us
# remainder when 6 is divided by 2 that is 0. Let us take 9, 9%2 gives us
# remainder when 9 is divided by 2 that is 1. So we can say that if n%2
# is 1,then n is odd, otherwise it is even

n = int(input("Enter an odd number between 30 and 80 ")) # ask for the input

if n<30 or n>80: # if n is less than 30 or more than 80
if n%2 == 0: # and also if n is even
print("That input was out of range and not odd") # print the result
  
else: # if n is less than 30 or more than 80 and n is odd
print("That was odd but out of required range") # print the result
  
  
elif n>30 and n<80: # if n is more than 30 and less than 80
if n%2==0: # and also if n is even
print("That was in range but it was even, not odd") # print the result
  
else: # if n is more than 30 and less than 80 and also n is odd
print("Good input") # print the result
  

  

Code Screenshot -

Output Screenshot -

PLEASE REFER TO THE CODE SCREENSHOT FOR PROPER INDENTATION.

ALL THE BEST !!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
python 3 A grocery store keeps track of the fruits it has sold. Currently it only...
python 3 A grocery store keeps track of the fruits it has sold. Currently it only tracks apples and bananas. Write a program that first asks the user to enter how many days he/she wants to record, then for each day prompts the user to enter the profit of selling apples and bananas respectively. The program should display the total profit made by selling the two fruits over all these days, and show which fruit -- apples or bananas --...
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
Write a java program that creates an integer array with 50 random values, prompts the user...
Write a java program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. “Out of Bounds”) and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle invalid inputs,...
Python Programming Assignment 3 For this assignment you have been given a starting file to use...
Python Programming Assignment 3 For this assignment you have been given a starting file to use for the assignment. Some code is already in this file, and it provides functionality you’ll be using to complete this assignment. Your code needs to go in a specific place, marked #### Your Code Here You code must go under this comment, and you should not modify the other parts of the file, except to add a block comment at the top with your...
Please program in JAVA: Program each option such as delete line and such. Your program will...
Please program in JAVA: Program each option such as delete line and such. Your program will be a line editor. A line editor is an editor where all operations are performed by entering commands at the command line. Commands include displaying lines, inserting text, editing lines, cutting and pasting text, loading and saving files. For example, a session where the user enters three lines of text and saves them as a new file may appear as: Menu: m Delete line:...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with a Program class and write the following two methods (headers provided) as described below: - A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number...
Java please. Need to use a linked list only. Many people have used pulling petals off...
Java please. Need to use a linked list only. Many people have used pulling petals off roses and tossing them in the air to determine if someone loves them or not. Your sister wants to use roses to determine which one of several suitors she will let take her to the prom. A linked list can be used to represent the prom date suitors. Write a program to simulate her decision and determine her prom date. The simulation will work...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT