print('Welcome to our hours of study calculator! Easily determine how many hours you have to study based on the grade you want! Thank you for using my program! Have a great day.') #initalize variables run_again = 'Y' total_credits = 0 allstudents_studyhours = 0 total_students = 0 while run_again.upper() == 'Y':#Loop continues as long as user enters Y     full_name = ""     #str     first_name = ""     last_name = ""     full_name = ""     grade_wanted = ""     credits_taken = ""     #int          number_of_classes = 0     studyhours_needed = 0     total_number_studyhours_perstudent= 0           #list     grades = ['A','B','C','D','F']     first_name = input('Please enter your first name:') #1-Ask user's first_name     while first_name =="": #validate that the user entered a name.         print('You must enter a valid name:')         first_name = input('Please enter your first name:') #1A-Ask user's last_name     last_name = input('Please enter you last name:')       while last_name == "":#validate that the user entered a last name         print('You must enter a valid last name:')         last_name = input('Please enter you last name:')  #2-Ask user how many credits they are taking     credits_taken = input('Please enter number of credits youre taking:')         while not credits_taken.isdigit() or int(credits_taken) < 3 or int(credits_taken)> 18 or int(credits_taken) % 3:  #validation of credits each student is taking.         print('Enter a valid number of credits you are taking, if each class is 3 credits:')         credits_taken = input('Please enter number of credits youre taking:')        #3-Ask user what grade they would like to receive(assume same for all classes.)     grade_wanted = input('Please enter the grade wanted for your classes:')     while not grade_wanted.upper() in grades:          #validating grades         print( 'Please enter a valid grade:')         grade_wanted = input('Please enter the grade wanted for your classes:')     grade_wanted = grade_wanted.upper() ####Calculations ##4 We are calculating the total number of classes the student is taking     number_of_classes = (int(credits_taken) / 3) ##5 Calculating the total number of hours student will have to study, per class, to acheive the grade wanted. Assume the same for each class.     if grade_wanted == 'A':         studyhours_needed = 15     elif grade_wanted == 'B':         studyhours_needed = 12     elif grade_wanted == 'C':         studyhours_needed = 9     elif grade_wanted == 'D':         studyhours_needed = 6     else:         grade_wanted == 'F'         studyhours_needed = 0         ##6 Calculating the total number of hours the student must study for all classes.     total_number_studyhours_perstudent = (number_of_classes * studyhours_needed) ##7 We are going to display the following information to the user.         print('Name:',first_name + " "+ last_name)     print('Credits:', credits_taken)     print('Study Hours:',total_number_studyhours_perstudent)     print('Grade:', grade_wanted) ##8 Calc the total number of students who used the program.     total_students = total_students + 1 ##9 Calc total number of credits taken by all students who used the program.     total_credits = total_credits + int(credits_taken)    # print(total_credits) #10 Calc total number of study hours for all students who used the program.     allstudents_studyhours = total_number_studyhours_perstudent + allstudents_studyhours    # print(allstudents_studyhours) #11 This will determine if you would like to keep running the program, or quit.     run_again = input('Would you like to continue using the program? If yes, please enter Y, any other key will exit') #12 Calculate and display the following information to the user. print('Total Students:', total_students) print('Average Credits:', total_credits / total_students) print('Average Study Hours:', allstudents_studyhours / total_students)   I need this is function format. This question was refused because of name validation--it just has to be letters and a non null value. It has to be Python language, not C++.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

print('Welcome to our hours of study calculator! Easily determine how many hours you have to study based on the grade you want! Thank you for using my program! Have a great day.')


#initalize variables

run_again = 'Y'

total_credits = 0
allstudents_studyhours = 0
total_students = 0

while run_again.upper() == 'Y':#Loop continues as long as user enters Y
    full_name = ""

    #str
    first_name = ""
    last_name = ""
    full_name = ""
    grade_wanted = ""
    credits_taken = ""

    #int
    
    number_of_classes = 0
    studyhours_needed = 0
    total_number_studyhours_perstudent= 0
    
     #list
    grades = ['A','B','C','D','F']

    first_name = input('Please enter your first name:')
#1-Ask user's first_name
    while first_name =="": #validate that the user entered a name.
        print('You must enter a valid name:')
        first_name = input('Please enter your first name:')
#1A-Ask user's last_name
    last_name = input('Please enter you last name:')  
    while last_name == "":#validate that the user entered a last name
        print('You must enter a valid last name:')
        last_name = input('Please enter you last name:') 
#2-Ask user how many credits they are taking
    credits_taken = input('Please enter number of credits youre taking:')    
    while not credits_taken.isdigit() or int(credits_taken) < 3 or int(credits_taken)> 18 or int(credits_taken) % 3:  #validation of credits each student is taking.
        print('Enter a valid number of credits you are taking, if each class is 3 credits:')
        credits_taken = input('Please enter number of credits youre taking:') 
     
#3-Ask user what grade they would like to receive(assume same for all classes.)
    grade_wanted = input('Please enter the grade wanted for your classes:')
    while not grade_wanted.upper() in grades:          #validating grades
        print( 'Please enter a valid grade:')
        grade_wanted = input('Please enter the grade wanted for your classes:')

    grade_wanted = grade_wanted.upper()
####Calculations
##4 We are calculating the total number of classes the student is taking
    number_of_classes = (int(credits_taken) / 3)

##5 Calculating the total number of hours student will have to study, per class, to acheive the grade wanted. Assume the same for each class.
    if grade_wanted == 'A':
        studyhours_needed = 15
    elif grade_wanted == 'B':
        studyhours_needed = 12
    elif grade_wanted == 'C':
        studyhours_needed = 9
    elif grade_wanted == 'D':
        studyhours_needed = 6
    else:
        grade_wanted == 'F'
        studyhours_needed = 0
       
##6 Calculating the total number of hours the student must study for all classes.
    total_number_studyhours_perstudent = (number_of_classes * studyhours_needed)

##7 We are going to display the following information to the user.    
    print('Name:',first_name + " "+ last_name)
    print('Credits:', credits_taken)
    print('Study Hours:',total_number_studyhours_perstudent)
    print('Grade:', grade_wanted)

##8 Calc the total number of students who used the program.
    total_students = total_students + 1

##9 Calc total number of credits taken by all students who used the program.
    total_credits = total_credits + int(credits_taken)
   # print(total_credits)
#10 Calc total number of study hours for all students who used the program.
    allstudents_studyhours = total_number_studyhours_perstudent + allstudents_studyhours
   # print(allstudents_studyhours)
#11 This will determine if you would like to keep running the program, or quit.
    run_again = input('Would you like to continue using the program? If yes, please enter Y, any other key will exit')

#12 Calculate and display the following information to the user.
print('Total Students:', total_students)
print('Average Credits:', total_credits / total_students)
print('Average Study Hours:', allstudents_studyhours / total_students)

 

I need this is function format. This question was refused because of name validation--it just has to be letters and a non null value. It has to be Python language, not C++.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education