What is `raw_input()`?


#1

What is a raw_input? And why a parenthesis needed after raw_input although python 2 is being used?


FAQ: Learn Python – Strings & Console Output – String Formatting with %, Part 2
FAQ: Learn Python – Strings & Console Output – String Formatting with %, Part 2
#2

its a built-in function

calling a function always requires parentheses.


#3

Thank you for your response @stetim94, if you don’t mind could you explain in detail about the usage of raw_input during codding and the difference of a function and a built-in function? Sorry for the trouble, i am a newbie in this


#4

its a built-in function so you can get input from the user.

a function is one you write, a built-in function ships with the python language. They are both functions, so in a sense they are the same


#5

Thank you so much for your help, can i understand the concept of built-in function similar to result keywords such as True = 1, and False = 0 that is fixed with python?


#6

True and False are Boolean’s, but yes, they come bundled with the python language as well.


#7

Thank you, @stetim94, this is a question outside of the exercise, but hope you could help with it. What is a signed integer and unsigned integer and how does it effect our code? when is it necessary to use a singed and unsigned integer?


#8

No idea, seems more relevant to C then python:

https://stackoverflow.com/questions/20766813/how-to-convert-signed-to-unsigned-integer-in-python


#9

@stetim94, thanks for the source, say i have completed the course of python, where would you suggest me to proceed in implementing it? Where can i really try to use what i learned?


#10

you can install python on your computer. Which gives you the python IDLE as well as the ability to run python scripts with the interpreter.


#11

@stetim94, can i know what is a python IDLE? And with python downloaded, what can i do with it. What can i create, any ideas?


#12

@stetim94, i just met a problem, the 4 in %04d should means that 4 spacing is allowed, correct? If that is so, then why when i print the date # print ‘%02d/%02d/%01d’ % (now.month, now.day, now.year) the year still shows 4 digits # 2018 although in my code only one digit is allow for year? And i don’t quite understand the use of the d in %02d. I hope you don’t mind my non-stop questions, thank you so much for your response.


#13

IDLE = integrated development and learning enviroment

python is a general purpose programming language, you can do many things. Back-end of a website, scrapers and much more.

i don’t think you can use 01 to display less digits then the variable holds

%d is a placeholder for a decimal variable, just like %s is for a string. Its a good way to insert variables into a string


#14

so that means that i can’t make it lesser by using 01 but i can expend it to 4 or more digits example using 05 , is that right. But i can still add a float value using %s although %s is for a string variable example, float1 = 0.3 print ‘This is float1 %s’ % (float1)


#15

yes, exactly

but %s only allow strings, you can’t use floats with %s