-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek4programming.py
More file actions
66 lines (49 loc) · 1.51 KB
/
week4programming.py
File metadata and controls
66 lines (49 loc) · 1.51 KB
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
"""
Programming Activity 1
Write a program that asks the user the year they were born. Display a message telling the user what generation they belong to based on the following rules/years:
- Zoomer 1997
- Millennial 1981
- Gen X 1965
- Baby Boomer 1946
"""
birthyear = int(input("What year where you born:"))
if birthyear >= 1997:
print("You are a Zoomer")
elif birthyear >= 1981:
print("You are a Millennial")
elif birthyear >= 1965:
print("You are a GenX")
elif birthyear >= 1946:
print("You are a Baby Boomer")
else:
print("You are born before the Baby Boomer generation.")
"""
Programming Activity 2:
Write a program which asks the user their age, then using a while loop displays the year they were born, using the following rules:
- continue the loop while age is greater than 1
- print each time "you were alive in year: " current_year
- decrease age and current_year by one each time
- add an else saying "you were born in year: " current_year
"""
age = int(input("what is your age:"))
current_year = 2026
while age > 1:
print("you were alive in", current_year)
age -= 1
current_year -= 1
else:
print("you were born in", current_year)
"""
Programming Activity 3
Write a program that prints all the multiples of 5, from 5 to 95 using a for loop.
"""
for number in range(5, 100, 5):
print(number)
"""
Programming Activity 4
Write a program that prints all the multiples of 5, from 5 to 95 using a while loop.
"""
number = 5
while number <= 95:
print(number)
number += 5