Review:
There is 1 basic way for Python 3 to get info from a user:
input - this command stores the value as a string
int(input(" ") - this converts what is input into an integer or numerical value
Let's try an example:
Guiding Questions;
Explanation of Code:
To allow the user to enter information, you need to know TWO things:
There are two types of inputs:
When you make an input, you're giving the user a chance to enter information. That information must be in the form of either a string or integer.
The input function allows you to also print text that is within its quotes
An input must be stored in a variable so you can use it later. You can call this variable anything you want but it should be related to what kind of information is being stored.
Example 1:
name = input("What is your name?")
This line of code stores whatever the user enters as a name into the variable called name. It also prints the line "What is your name?"
Example 2:
age = int( input("What is your age?"))
This line of code stores whatever the user enters as their age into the integer variable called age. It also prints the line "What is your age?"
Adding Variables to Inputs
The input statement can print ONE string.
So you can print variables inside of Input statements as long as you make what's in the brackets one string using +
Keep in mind that only strings can be merged with strings so if you want to put an integer inside, you need to convert the integer to a string:
Try the program below
Assignment #2
Make a program that does the following:
If you have any questions about specifics...ASK!
Submit your assignment in the standard link below.