True
True
False
False
True and False
False
True or False
True
not False
True
4 + 5
9
4 * 5
20
4 - 5
-1
5 / 2
2.5
5 // 2
2
5 % 2
1
2253 // 100
22
2253 % 100
53
"hello"
'hello'
'''hello'''
'hello'
'''
select fname
from students
where major = 'CSC'
'''
"\nselect fname\nfrom students\nwhere major = 'CSC'\n"
"hello" + " " + "how are you?"
'hello how are you?'
len("hello")
5
"123"
'123'
int("123")
123
int("123a")
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [23], in <cell line: 1>() ----> 1 int("123a") ValueError: invalid literal for int() with base 10: '123a'
try:
int("123a")
except:
print("conversion error")
#sys.exit()
conversion error
x = 5
print(x)
x = 6
print(x)
5 6
print(5 > 7)
5 == 7
5 <= 7
5 < 7
5 >= 7
5 != 7
False
True
hour = 2
if hour == 0:
shour = "zero"
elif hour == 1:
shour = "one"
elif hour == 2:
shour = "two"
else:
shour = "twenty three"
print(shour)
two
# conditional statement
age = 17
if age > 12 and age < 20:
print("Teenage")
else:
print("not teenage")
Teenage