-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercises 5.py
More file actions
49 lines (39 loc) · 979 Bytes
/
Copy pathExercises 5.py
File metadata and controls
49 lines (39 loc) · 979 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
#Phase 1
import random
number = int(input("How many dice to roll?"))
rolls = []
for i in range(number):
x = random.randint(1, 6)
rolls.append(x)
print("sum of all dices is:", sum(rolls))
#phase 2
print("Pleas enter at least 5 numbers")
list_number = []
num = input("Give a number: ", )
while num != "":
list_number.append(num)
num = input("Give a number: ", )
list_number.sort(reverse=True)
print("The first 5 greatest number are: ")
for i in range(5):
print(list_number[i], end=" ")
#phase 3
num = int(input("Enter a integer number"))
divisible = False
if num > 1:
for i in range(2, num-1):
if num % i == 0:
divisible = True
break
if divisible == False:
print("This is a prime number")
else:
print("This is not a prime number")
#phase 4
print("Give the name of 5 cities")
cities = []
for i in range(5):
name = input("Enter the name:",)
cities.append(name)
for i in range(5):
print(cities[i])