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#basic user handling for begginers
2
3x = input("your question here") # when someone types something here that answer will be saved and be used for later
4
5# for example
6print(x)
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
1# if you want to ask the user to input anything, use the keyword "input"
2
3# example
4
5a = input("What is your name") # the user will be prompted to answer the question
6
7print(a) # this allows the user to actaully see the question or anything