-
Notifications
You must be signed in to change notification settings - Fork 2
/
intro_to_python.py
86 lines (66 loc) · 1.88 KB
/
intro_to_python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# HelloWorld.py
# def PrintHelloWorldTenTimes():
# for num in range(1, 11):
# print(f'Hello World #{num}')
# PrintHelloWorldTenTimes()
# for number in range(5):
# print ('Hello World')
# for number in range(5):
# numberToPrint = number + 1
# if (numberToPrint) % 2 == 0:
# print (f'Even Hello World #{numberToPrint}')
# else:
# print (f'Odd Hello World #{numberToPrint}')
# while True:
# print('Hello World')
# break
# number = 1
# while number <= 5:
# print (f'Hello World #{number}')
# number = number + 1
# numbers = [1, 2, 3, 4, 5]
# for number in numbers:
# print (f'Hello World #{number}')
# class Person:
# def __init__(self, name, age, gender):
# self.name = name
# self.age = age
# self.gender = gender
# def introduce(self):
# print("Hello, my name is " + self.name)
# tim = Person("Tim", 28, "Male")
# tim.introduce()
# mary = Person("Mary", 30, "Female")
# mary.introduce()
# for number in range(5):
# numberToPrint = number + 1
# if numberToPrint % 3 == 0:
# print (f'{numberToPrint} is divisible by 3')
# elif numberToPrint % 2 == 0:
# print (f'{numberToPrint} is even')
# else:
# print (f'{numberToPrint} Not even and not divisible by 3')
# letters = ['a', 'b', 'e']
# print('starting letters: ',letters)
# letters.append('c')
# print('append c: ',letters)
# letters.insert(2, 'd')
# print('insert d at position 2: ', letters)
# letters.remove('a')
# print('remove a: ',letters)
# my_list = [[1,2,3,4], [5,6,7,8], [9,10,11,12]]
# value = my_list[2][3]
# print(value)
my_dict = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3'
}
# value = my_dict.get('key4', 'default_value')
# print(value)
# for key in my_dict:
# print(key)
# for value in my_dict.values():
# print(value)
for key, value in my_dict.items():
print(key, value)