-
Notifications
You must be signed in to change notification settings - Fork 4
/
basics.py
73 lines (56 loc) · 1.1 KB
/
basics.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
# comment
"""
multline comment
"""
# float
# int
# string
# class
# dict
# tuple
# list
weight = 12.4
age = 12
name = "Iden"
my_books = {
"name": "Book One",
"age": 12,
"likes": {
"sports": "Foot ball"
}
}
ages = (1, 2, 3)
ages2 = 1,2,3
my_list = list(ages)
# list -> []
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
print("class created!")
def print_info(self):
# return f"name is {self.name} and age is {self.age}"
return "name is " + self.name + " and age is " + str(self.age)
person = Person("iden", 12)
print(person.print_info())
# dict methods
for keys in my_books.keys():
print(keys)
for keys, values in my_books.items():
print(f"{keys} => {values}")
# for number in my_list:
# print(number)
count = 0
while count != len(my_list):
print(my_list[count])
count += 1
my_list.append(56)
print(my_list.count(2))
my_name = input("enter a name: ")
letter_count = 0
for letter in my_name:
if "a" == letter:
letter_count += 1
else:
continue
print(letter_count)