Variables and Input APCSP Assignment - SB
Along with everything above, you are also going to figure out how getting user input works in this activity. When you are finished, submit your program for review.
Create a new Python Repl.it called, "Variables and User Input".
Add your name, date, and assignment name at the top using comments.
Enter the following line of code underneath the comments: name = input("Please enter your name: ")
What is the value of name after this line has executed?
Add a print function afterward saying hello to the person who just entered their name. Use concatenation to join together their name and your salutation. Example: print("Welcome " + name + "."). This statement will display the value of name
Run and test your program, fixing any errors so that it executes as expected.
Prompt the user for another input, this time asking them for their age.
Use a line similar to: age = input("How old are you? ")
On the next line, take the age the user entered and add 10 to it: age = age + 10
After that line, print back to the user with an output that uses both the name and age variables and tells the user how old they will be in 10 years.
Run and test your program... uh oh. Error?
Go back to the line where you got your input for age and typecast the input as an int: age = int(input("How old are you? "))
Now run and test your program again... uh oh... another error?
Finally, go to the print statement and typecast the variable - age - as a string. Your output should look like:
print(name + ", you will be " + str(age) + " years old in 10 years.")
Add at least two comments in the program documenting what the program is doing, changes that you made in order to make it unique, or important notes to yourself about what you learned.