1#Collecting The Input As A Variable:#
2name = input('Please enter your name: ')
3#Printing The Variable:#
4print(name)
5#Checking The Variable And Printing Accordingly:#
6if name == 'Joe':
7 print('Joe Mama')
1name = input("What is your name?\n") # Asks the user 'What is your name?' and stores it in the 'name' variable
2
3print("You said your name was " + name)
4
5number = int(input("Please select a random number:\n")) # Will get input as a number
6# Will error if the value entered is not a number
7
8# You can use any type of conversion (int(), bool(), float(), etc.) to modify your input
9
10
1# First, let's start with a simple input function.
2input("What's your name?: ") #This will ask you what is your name, and you can input anything you want.
3#The above code is simple, and theres not much you can do with it.
4
5# Let's get a little harder!
6name = input("What is your name? ") # Just adding a variable doesn't look like much, but it goes a long way!
7print("Hello," , name , ", I'm dad!") # THis will print Hello [your name] I'm dad when the user inputs a name.
8
9# Let's make this a little more advanced!
10name = input("What is your name? )
11if name == "Dad": # Now if sombody inputs 'Dad' as there name:
12 print("Hi dad I'm- wait a minute...") # it will say this
13else: # If a user prints anything else:
14 print("Hi" , name , "I'm dad!") # It will output this!
15
16# What if I want to add multiple names? Well, that's entirly possible, with the elif statment
17if name == "Dad": # If the user inputs "Dad" as their input:
18 print("Hi Dad, I'm- stop trying to trick me D:<") # It will output this
19elif name == "Doggo": # If the name is "Doggo":
20 print("Hi doggo- wait your not supposed to talk?") # It will output this:
21# Using the elif statment, we can make an entirley different with only one question asked
22else:
23 print("Hello, ", name, "!") # We always end an if statment with an else one.
24
25# Hope this helped! :D