A Byte of Python
#
# Note that print is a function print('hello world')
print('hello world') # Note that print is a function
5
1.23
'This is a string'
"It's a string!"
True
False
None
Numbers are mainly of two types - integers and floats.
2
3.23
52.3e-4
e
52.3 * 10^-4^
'Hello' "Hello" ''' This is a multi-line string '''
name = 'Swaroop' age = 20 print(f'{name} was {age} years old')
\
\'
\"
\\
\n
\t
>>> print("foo") foo
>>> print("foo\nbar") foo bar
>>> print("foo\n\nbar") foo bar
>> i = 5 >> print(i) 5 >> i = i + 1 >> print(i) 6
myname
myName
age
name
foo
bar
age2
name_2
foo_bar
_age
_name
_
AGE
NAME
i
j
k
df
x
y
X
Y
>>> i = 5 >>> type(i) <class 'int'> >>> i = 'foo' >>> type(i) <class 'str'>
i = 5 print(i)
i = 5; print(i)
if True: print('True') else: print('False')