Syntax, Strings and Console Output Flashcards
variable assigning
variableName = ‘string or anything’
Accesing the letter from a string, first for example.
“Maciej”[0] == ‘M’
Function return length of an object, string for example.
len(“string”)
Function creating string from object, number for example.
str(1)
Function returning string in lower cases.
string.lower()
Function returning all letters in upper case.
string.upper()
Does Python do string concatenation with + ? Does Python do it auctomatically.
Yes, it uses + for concatenation, but Python is strongly typed.
Simple function for printing text
print “Hello world”
Formated printing.
print “The string is %s” % (varableString)
Multiple variables formated print
print “%s, %s, %s” % (name, last, age)
Reading from input
raw_input(“Messege for input”)