-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExerciseLists.py
57 lines (43 loc) · 1.23 KB
/
ExerciseLists.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
#-*- coding: utf-8 -*-
# For finish the lessons, go making with me one list of exercises
# 1 - Make a program that receive the age of a user and tell if him is a adult
def isadult(age):
if age < 18:
print("Isn't adult")
else:
print("Is adult")
isadult(11)
isadult(18)
# 2 - Make a program that receive two grades for the user. If grade is bigger or same six, write aproved,
# else write reproved.
def isaproved(note1,note2):
media = (note1+note2) / 2;
if media > 5:
print("Aproved")
else:
print("Reproved")
isaproved(3,8)
isaproved(1,7)
# 3 - Write a program what order a numeric list with three elements.
def numericlist(num1,num2,num3):
nlist = [num1,num2,num3]
nlistorder = sorted(nlist)
print(nlist)
print(nlistorder)
numericlist(3,8,4)
numericlist(1,7,2)
# 4 - Write a program what receive two number and a operator, and make the mathematical operation.
def mathematicaloperatin(num1,num2,operator):
if operator == '+':
print(num1 + num2)
elif operator == '-':
print(num1 - num2)
elif operator == '/':
print(num1 / num2)
elif operator == '*':
print(num1 * num2)
else:
print('Please insert a valid operator.')
mathematicaloperatin(9,8,'-')
mathematicaloperatin(2,5,'*')
mathematicaloperatin(2,2,'%')