forked from werhereitacademy/Python_Modul_Week_1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMohammad_week 1
More file actions
115 lines (99 loc) · 2.45 KB
/
Mohammad_week 1
File metadata and controls
115 lines (99 loc) · 2.45 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Question 1#
#########
for i in range(1,11):
print(i)
# Question 2
#########
num = int(input("Enter thenumber: "))
print("Even numbers to", num, "are:")
for i in range(0, num + 1, 2):
print(i)
print("Even numbers to", num, "are:")
i = 0
while i <= num:
print(i)
i += 2
# Question 3
##########
start = int(input("Enter the first number: "))
end = int(input("Enter the last number: "))
print("the range between", start, "and", end, "are:")
for num in range(start, end + 1):
print(num)
# Question 4
########
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is an even number.")
else:
print(num, "is an odd number.")
# Question 5
#########
num = int(input("Enter a positive integer: "))
if num < 0:
print("Please enter a positive integer.")
else:
x = 1
for i in range(2, num + 1):
x*= i
print(x)
# Question 6
########
n = int(input("Enter a number: "))
if n <= 1:
print("false")
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
print("is not a prime number.")
else:
print(n, "is a prime number.")
# Question 7
#########
n = int(input("Enter a number: "))
fib_seq =[]
a,b = 0,1
while a<= n:
fib_seq.append(a)
a,b = b,a + b
print(fib_seq)
# Question 8
########
word = input("Enter a word :")
rev_word = word[::-1]
print("rev_word = ", rev_word)
# Question 9
#########
word = input("Enter a word :")
if word == word[::-1]:
print("the word is a palindrome.")
else:
print("the word is not a palindrome.")
# Question 10
# #######
weight = float(input("Enter your weight (kg): "))
height = float(input("Enter your height (m): "))
x = weight / (height ** 2)
if x < 25:
print("You are underweight.")
elif x < 30:
print("Your weight is normal.")
elif x <= 40:
print("You are overweight.")
else:
print("You are severely overweight.")
# Question 11
# #######
numbers = input("Enter numbers separated by spaces: ").split()
largest_three = sorted(numbers, reverse=True)[:3]
print("The largest three numbers are:", largest_three)
# Question 12
# #######
for i in range(1, 5):
print(f"Enter grades for Lesson {i}:")
mid = float(input("Enter your midterm grade: "))
fin = float(input("Enter your final grade: "))
average = (mid * 0.4) + (fin * 0.6)
if average < 50:
print(f"Lesson {i}: FAILED\n")
else:
print(f"Lesson {i}: SUCCESSFUL\n")