print("Hello world!") print("Hello", "world!") x=5 y=-3 print(x, type(x)) print(y, type(y)) x = 5.5 print(type(x)) x=5.0 y=-3.2 z=2.2e6 print(x, type(x)) print(z, type(z)) x = "CS1001.py" y = 'I love python' print(x, type(x)) print(y, type(y)) print(type(4), type(4.0), type("4")) i_love_python = True python_loves_me = False print(i_love_python, type(i_love_python)) print(python_loves_me, type(python_loves_me)) 4 + 5 x = 5 4 + x x = 4.0 + 5 print(x, type(x)) x - 3 x * 3 10 / 3, 10 // 3 2 ** 3, 2 ** 3.0, 3 ** 2 10 % 3 "Hello" + " World" "Bye" * 2 4 + 5 "4" + "5" "4" + 5 4 + "5" 5 < 4 5 > 4 5 >= 4 4 >= 4 4 <= 3 5 == 4 5 == 5.0 5 == "5" 5 != 4 2 + 2 == 4 2 => 3 x = 1 / 3 print(x) x == 0.3333333333333333 print(not True) a = 2 == 5 print(not a) True and True True and False False and False True or True True or False x = "6" print(x, type(x)) x = int("6") print(x, type(x)) float("1.25") str(4) int("a") course = "intro" + str(2) + "cs" print(course) print("intro", 2, "cs", sep='') today = "Monday" strike = "N" my_recitation = "Monday" if today == "Sunday": print("Shvizut Yom Alef") if strike == "Y": print("Stay home") else: print("Lecture in intro to CS!") elif today == "Wednesday": print("Another lecture in intro to CS!") elif today == my_recitation: print("Go to recitation!") elif today == "Monday" or today == "Tuesday" or today == "Thursday" or \ today == "Friday" or today == "Saturday": print("no intro to CS") else: print("Not a day") num = 2**100 print(num) count = 0 while num > 0: #what if we changed to >=0? if num % 10 == 0: count = count + 1 num = num // 10 print(count) num = 2**100 count = 0 for digit in str(num): #print(digit, type(digit)) if digit == "0": count = count + 1 print(count) num = 2**100 count = str.count(str(num), "0") print(count) %%timeit num = 2**100 count = 0 while num>0: #what if we changed to >=0? if num % 10 == 0: count = count + 1 num = num // 10 %%timeit num = 2**100 count = 0 for digit in str(num): if digit == "0": count = count + 1 %%timeit num = 2**100 count = str.count(str(num), "0")