forked from atbudak/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Control_Flow_Statements.py
59 lines (46 loc) · 1.5 KB
/
Control_Flow_Statements.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
# Pre Class
# Conditional Statements
# If you need to remember the result of a condition check
# later in your code, use boolean variables as flags
gpa, lowest_grade = .9, .7
if gpa >= .85 and lowest_grade >= .7:
honor_role = True
else:
honor_role = False
# Somewhere later in our code
if honor_role:
print('Well Done')
# Loops
# * before range() function to separate its elements
# * can separate other iterable objects
print(range(5)) # it will not print the numbers in sequence
print(*range(5)) # '*' separates its elements
# In some cases, you will need to set up
# the for loop with multiple variables and the iterables.
text = ['one', 'two', 'three', 'four', 'five']
numbers = [1, 2, 3, 4, 5]
for x, y in zip(text, numbers):
print(x, ':', y)
# zip() function make an iterator that aggregates
# elements from each of the iterables.
# Lesson Notes
# String değerlerde ilk karakterin ASCII karşılıklarını karşılaştırır
value1 = '2020'
if value1 >= '1200':
print('string values checks by first value')
# boolean değer aldık kullanıcıdan
convert = input("yes or no ? ").title().strip() == 'Yes'
print(convert, type(convert))
num = int(input("Enter a number: ").strip())
if num % 2 == 0:
print(f"{num} is even")
else:
print(f"{num} is odd")
num1 = float(input("Number 1 : "))
num2 = float(input("Number 2 : "))
if num1 > num2:
print(f"The large number is {num1}")
elif num1 == num2:
print(f"Both number is equal : {num2}")
else:
print(f"The large number is {num2}")