-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions-and-lists.py
More file actions
68 lines (51 loc) · 944 Bytes
/
functions-and-lists.py
File metadata and controls
68 lines (51 loc) · 944 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import random
a = -50
b = 50
myList = []
i = 0
size = 4
even = 0
odd = 0
w = 0
positive = 0
negative = 0
while i < size:
randNum = random.randint(a, b)
myList.append(randNum)
i += 1
m = max(myList)
n = min(myList)
ave = sum(myList)/len(myList)
aveMN = (m + n)/2
def check(num):
return bool(num % 2 == 0)
def within(num):
return bool(-25 <= num <= 25)
def plus(num):
return bool(num > 0)
def minus(num):
return bool(num < 0)
for x in myList:
if check(x):
even += 1
else:
odd += 1
for x in myList:
if within(x):
w += 1
for x in myList:
if plus(x):
positive += 1
for x in myList:
if minus(x):
negative += 1
print(myList)
print('even =', even)
print('odd =', odd)
print('within 25 =', w)
print('negative =', negative)
print('positive =', positive)
print('max =', m)
print('min = ', n)
print('average =', ave)
print('average max min =', aveMN)