+ 1
I dint get the difference between input and print, and how to use input function
5 Respuestas
+ 3
input() function prompts one to enter a value to be assigned to a variable in a code.
Eg. input_name = input("enter your name: ")
so the above ask one to type in name and the value saved in the variable input_name
print() function is used to display information to the user on the screen. This is because the above assignment happens background and one has no clue if indeed the name value was stored in the variable input_name, so to check that:
Eg. print(input_name)
and that displays the value of input_name from the input.
Hope it helps....happy coding!
+ 2
you can't learn python with only this learning app .. you have to install python on your pc and start writing some stuff just to get them clear.
if you type in:
print("hello")
and run the program , it will say hello.
if you tupe in:
print("What is your name ?")
input = name()
print("nice to meet you" + name)
and run the program it will ask you for your name..
the result would be:
What is your name?
____________ ( you enter your name here )
nice to meet you ________ ( whatever your name is).
+ 1
if we enter more than one word, it prints only the first word as an output. Why?
+ 1
input should prompt for the user to type in something that will be used in the program, print will display a message. Nebbo is almost correct but I think second line should be
name = input()
and you could also put a message to ask for input as part of input like
name = input("what is your name?" )
instead of doing a print and then getting input
0
Why not just have
I put a space after the question mark and behind hello before the ” so it looks right when it runs. You can have the name as long as you want it.
name = input ("what is your name? ")
print ("hello " + name)