In: Computer Science
Q.1 Write a python program that will take in basic information from a student, including student name, degree name, number of credits taken so far, and the total number of credits required in the degree program. The program will then calculate how many credits are needed to graduate. Display should include the student name, the degree name, and credits left to graduate.
Write two print statements in this program. In the first one, use the .format method with pre-specified order of the displayed outputs.
In the second print, using different % operators to display the output. Make sure to display the output in an aligned format (look into a sample of the output below..).
Student name: xyz xyz
Degree name: comp. engineering
Credit taken so far: 13
Total number of credits required: 33
Number of credits needed to graduate: 20
Q.2 Write a python program that will take in the number of call minutes used. Your program will calculate the amount of charge for the first 200 minutes with a rate of $0.25; the remaining minutes with a rate of $0.35. The tax amount is calculated as 13% on top of the total. The customer could have a credit that also has to be considered in the calculation process. Finally, the program displays all these information. Below is a sample run:
Customer account number: 12345
Minutes used: (you provide)
Charge for the first 200 minutes@ 0.25: (you provide)
Charge for the remaining minutes@ 0.35: (you provide)
Taxes: (you provide)
Credits: (you provide)
Total bill: (you provide)
please provide .py program file screenshot and output.
In case of Multiple question we have to answer one question due to time constraint, please ask second question as a separate question
QUESTION 1)
CODE:
Using .format:
name = input("Student Name: ")
deg = input("Degree Name: ")
cr = input("Credit taken so far: ")
total = input("Total number of Credits required: ")
need = int(total)- int(cr)
#print using .format
print("Student Name: {}".format(name))
print("Degree Name: {}".format(deg))
print("Credit taken so far: {}".format(cr))
print("Total number of Credits required: {}".format(total))
print("Number of Credits required: {}".format(need))
CODE SNIPPET AND OUTPUT:
Print USING % sign:
CODE:
name = input("Student Name: ")
deg = input("Degree Name: ")
cr = input("Credit taken so far: ")
total = input("Total number of Credits required: ")
need = int(total)- int(cr)
#print using % sign
#%s for string %d for integer
print("Student Name: %s" %name)
print("Degree Name: %s" %deg)
print("Credit taken so far: %s"%cr)
print("Total number of Credits required: %s"%total)
print("Number of Credits required: %d"%need)
CODE SNIPPET AND OUTPUT:
Ask doubts if any, upvote if you liked it.