OBTAINING INPUT
INPUTTING A VARIABLE
• When a value in entered from the user it needs to be
stored somewhere
• Question: What do we use to store information?
• Not much different than assigning a variable
• Prompts!!!
 
CODE TO INPUT A VARIABLE
 How to input values from the user 
› Code: variable = input(“Prompt “)
› variable – stores the input from the user.
› input – function to extract user input from the
command prompt.
› “Prompt” – a string to inform the user of the type of
value to enter.
 Ex. Inputting a numerical value
testGrade1 = input(”Enter test grade 1: “)
testGrade *= 100 
print(”Test Grade: “, testGrade, “%”)

Input

  • 1.
  • 2.
    INPUTTING A VARIABLE •When a value in entered from the user it needs to be stored somewhere • Question: What do we use to store information? • Not much different than assigning a variable • Prompts!!!  
  • 3.
    CODE TO INPUTA VARIABLE  How to input values from the user  › Code: variable = input(“Prompt “) › variable – stores the input from the user. › input – function to extract user input from the command prompt. › “Prompt” – a string to inform the user of the type of value to enter.  Ex. Inputting a numerical value testGrade1 = input(”Enter test grade 1: “) testGrade *= 100  print(”Test Grade: “, testGrade, “%”)