#Collecting The Input As A Variable:#
name = input('Please enter your name: ')
#Printing The Variable:#
print(name)
#Checking The Variable And Printing Accordingly:#
if name == 'Joe':
print('Joe Mama')
name = input("What is your name?
") # Asks the user 'What is your name?' and stores it in the 'name' variable
print("You said your name was " + name)
number = int(input("Please select a random number:
")) # Will get input as a number
# Will error if the value entered is not a number
# You can use any type of conversion (int(), bool(), float(), etc.) to modify your input
#basic user handling for begginers
x = input("your question here") # when someone types something here that answer will be saved and be used for later
# for example
print(x)
# we make the input to take the name of user
name = input("inter your name : ")
# this input to take the age
age = input("inter your age : ")
# the print to say to user hi and this is your age
print(f"hi {name} your age is {age}")
# Taking string input
a = input("Enter a string: ")
print("String is: ", a)
# Taking integer input
b = int(input("Enter an integer: "))
print("Integer is: ", b)
# Taking float input
c = float(input("Enter a float value: "))
print("Float value is: ", c)
#The input command will popup/print the text placed inside the brackets.
#After the text you can type anything and press enter.
#Then the stuff written in the ansfer field will be saved as the function value.
x = input("write anything after this: ")
print(x)
#This code will first print the stuff written in input (write anything after this:).
#Then it will store the text as the x value.
#Then it will print it.
x = input()
# This will take you to shell where you input a value for x
print(x)
# Print's the value you typed
y = input('Enter a number: ')
# Will print 'Enter a number: ' to the shell and then wait for you
# to enter a value (Does not have to be a number)
# Copy the code and try it
# use the function input()
# the parameter is something that would
# output on the screen before the input
name = input('What is your name?')
print('Hello ' + name)
age = input('what is your age?: ')
print("You are "+age + " years old")
ans : what is your age?: 23
You are 23 years old
#input method in python.A selected question would prompt and user should ans that.
#after that programme will show age with a text message.
#input or question, is used to ask question
ans = input('Who invented Microsoft?')
#An if statement
if(ans == 'Bill Gates'):
print('You got the answer')
# Python 3
txt = input("Type something to test this out: ")
# Note that in version 3, the print() function
# requires the use of parenthesis.
print("Is this what you just said? ", txt)
# An input is requested and stored in a variable
test_text = input ("Enter a number: ")
# Converts the string into a integer. If you need
# to convert the user input into decimal format,
# the float() function is used instead of int()
test_number = int(test_text)
# Prints in the console the variable as requested
print ("The number you entered is: ", test_number)
x = input ("Enter a phrase: ") #after slecting variable and input command,
#you have to write that string what you want to show in your terminal as input.
print (x) #to get the answer
#for integer
x = int (input("How many candies: ") #make sure using round figure, ex: 1, 2,
print (x)
#for decimal
x = float (input ("My height: ") #you can also use DOUBLE function instead of FLOAT
print (x)
#For this answer, I made a whole program, just to share with you input!
#This answer covers 2 other functions too. Don't worry those are easy!
user_input_stored_in_a_variable = input("Input: ").strip().lower()
print(f"Your input was {user_input_stored_in_a_variable}")
// if you want to take single int input
a=int(input())
// if you want n elements of array a as input from console/user
a = list(map(int,input().strip().split()))
# u can also covert it to set,tuple etc
# ex. set(map(int, input().strip().split()))
NOTE: suppose if you want a list with duplicates removed
list(set(map(int, input().strip().split())))
also note map is a method and is not hashmap which is actually disct in python.
and ommitting .strip() in 2nd argument of map func might also work.
# more explaination of above:
https://www.quora.com/What-does-the-following-line-mean-in-Python-list-map-int-input-strip-split-I
Use the input() method
Example
#code
name = input("Name Please: ")
print(f'Hello {name}, what can I do for you?')
#console
Name Please:
>>> Steve
Hello Steve, what can I do for you?