-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepeat.py
More file actions
55 lines (41 loc) · 898 Bytes
/
repeat.py
File metadata and controls
55 lines (41 loc) · 898 Bytes
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
# Variables & Data Types
x = 10 # int
pi = 3.14 # float
name = "Vlad" # str
is_admin = True # bool
items = [1, 2, 3] # list
person = {"age": 25, "city": "Düsseldorf"} # dict
# Conditions (if / else)
age = 20
if age >= 18:
print("Adult")
else:
print ("Child")
# Loops (for / while)
items = [10, 20, 30]
# for:
for item in items:
print(item)
# while:
counter = 0
while counter < 10:
print(counter)
counter += 1
# Functions
def greet(user_name):
return f"Hello, {user_name}"
print(greet("Vlad"))
# Lists
numbers = [10, 20, 30]
numbers.append(40) # add 40 into the lists
numbers.remove(20) # remmove 20 from the lists
print(numbers[2])
print(len(numbers)) # show the lenght of lists
# Dictionaries(dict)
user = {
"name": "Vlad",
"age": 26
}
print(user["name"])
user["country"] = "Germany"
print(user["country"])