0% found this document useful (0 votes)
6 views2 pages

Python Assignment Solutions

The document contains 3 Python programming questions. Question 1 calculates discounted totals for package orders over 10 items. Question 2 prints ascending star patterns from 1 to 8 lines. Question 3 takes 5 test scores as input, prints them with grades, and calculates the average score.

Uploaded by

matamela
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Python Assignment Solutions

The document contains 3 Python programming questions. Question 1 calculates discounted totals for package orders over 10 items. Question 2 prints ascending star patterns from 1 to 8 lines. Question 3 takes 5 test scores as input, prints them with grades, and calculates the average score.

Uploaded by

matamela
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Assignment

Question 3

3.1
num = int(input("Enter the number of the package: "))
retail = 99
amount = num * retail

if 10 <= num <= 19:


discount = amount * 0.1
tamout = amount + discount
print(tamout)
elif 20 <= num <= 49:
discount = amount * 0.2
tamout = amount + discount
print(tamout)
elif 50 <= num <= 99:
discount = amount * 0.3
tamout = amount + discount
print(tamout)
elif num >= 100:
discount = amount * 0.4
tamout = amount + discount
print(tamout)

3.2
for i in range(1, 9):
for j in range(1, i+1):
print("* ", end="")
print()

3.3
score = []
sum = 0

for i in range(5):
[Link](float(input("Enter score " + str(i+1) + ": ")))
sum += score[i]

print("---Test Scores---")
for j in range(5):
if 0 <= score[j] <= 49:
print("score " + str(j+1) + ": " + str(score[j]) + "\t" + "Grade: F")
elif 50 <= score[j] <= 59:
print("score " + str(j+1) + ": " + str(score[j]) + "\t" + "Grade: D")
elif 60 <= score[j] <= 69:
print("score " + str(j+1) + ": " + str(score[j]) + "\t" + "Grade: C")
elif 70 <= score[j] <= 79:
print("score " + str(j+1) + ": " + str(score[j]) + "\t" + "Grade: B")
elif 80 <= score[j] <= 100:
print("score " + str(j+1) + ": " + str(score[j]) + "\t" + "Grade: A")
print("Average score: " + str(sum/5))

You might also like