You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Input built-in function allows to receive input from the user while the programs runs. Program won't resume till you put your input
#We always want to assign the input built-in function to a variableanswer=input("How is the weather today")
print("The weather today is ", answer)
#You can force your inputs to receive specific types of variables:current_year=2021answer=int(input("What is your age?")) # We could use any built-in conversion function here we'd likeprint("Your year of birth is", current_year-answer)
Exercise:
Write a program that will receive three inputs, grade_one, grade_two, grade_three. Try to write a program that will print the average of the received three grades.
Answer:
#We need to force each input to be integers (float would also work)grade_one=int(input("What is the first grade?"))
grade_two=int(input("What is the second grade?"))
grade_three=int(input("What is the third grade?"))
avg= (grade_one+grade_two+grade_three) /3print("Average is:", avg)