Created
January 13, 2023 15:56
-
-
Save RichNSD/802d2444d20e42690cb54ccdb477a9e9 to your computer and use it in GitHub Desktop.
Basic 'User Input' example for Python beginners.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Come up with a series of variables to use in a 'def' function. | |
| """ | |
| # Include at least 1 variable with a 'pre-set' value | |
| Request = "Please enter your " | |
| """ | |
| Include at least 2 variables thay require User Input. | |
| Use the 'None' (aka 'Null') value to leave them 'declared' but undefined | |
| """ | |
| FirstName = None | |
| LastName = None | |
| Age = None | |
| """ | |
| Define a function to prompt the user to fill out the information. | |
| Run tests frequently to understand how the code behaves. | |
| """ | |
| def GetInput(): | |
| print("\n" + Request + "name below.") | |
| FirstName = input("First Name: ") | |
| LastName = input("Last Name: ") | |
| print("\n" + Request + "age.") | |
| Age = input("Age: ") | |
| GetInput() | |
| """ | |
| Finally, create a function definition that utilizes the new user input | |
| Don't forget to 'call' the function by entering its FunctionName() below | |
| """ | |
| def TestInput(): | |
| print("\n" + "My name is " + FirstName + LastName) | |
| print("\n" + "and I am " + Age + " years old." + "\n") | |
| TestInput() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment