- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_python_script.py
More file actions
Latest commit
30 lines (24 loc) · 735 Bytes
/
Copy pathsample_python_script.py
File metadata and controls
30 lines (24 loc) · 735 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
# This is a simple Python script that demonstrates the use of if-else statements and functions.
# Control flow with if-else statements and loops
cities= ['San Francisco', 'Los Angeles', 'New York', 'Atlanta']
forcityincities:
ifcity=='Los Angeles':
pass
else:
print(city)
forcityincities:
ifcity=='Los Angeles':
continue
else:
print(city)
# Looping through numbers and checking divisibility
forxinrange(1, 10):
ifx%2==0:
print('{} is divisible by 2'.format(x))
else:
print('{} is not divisible by 2'.format(x))
# This is a function that greets a person by name
defgreet(name):
x='Hello '+name
returnx
print(greet('Habtamu'))