forked from kaleemsiddiqu/edison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exam-3.py
executable file
·48 lines (35 loc) · 967 Bytes
/
exam-3.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
### This program is a simple examp program which asks users certain questions and
### base on the replies , marks are alloted.
from sys import argv
import random
#script, report = argv
def random_number(number):
number = random.randint(1, number)
return number
def test1(points_earned):
upperbound = 1000
n1 = random.randint(1, 1000)
s1 = "%d is a Even or Odd Number(Type \'even\' | \'odd\'): ?" % n1
print s1
answer = raw_input("> ")
result = even_odd_number(n1)
if result == answer:
points_earned += 1
else:
points_earned -= 1
report = s1 + answer
return report, points_earned
def even_odd_number(number):
if number % 2 == 0:
return 'even'
else:
return 'odd'
### Initialize variables
points_earned = 1
print " This is a simple test, where you will be asked simple questions regarding mathematics."
check = raw_input("Ready to take (y/n): ")
if check == 'y':
output=test1(points_earned)
print output
else:
print "Thanks"