-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvoting2.0.py
More file actions
68 lines (52 loc) · 2.04 KB
/
Copy pathvoting2.0.py
File metadata and controls
68 lines (52 loc) · 2.04 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
"""
1. create function to display welcome message
2. create function to display user message
3. create a function to take user details
4. create a function to validate the age for voting
5. create a function to display a thank you
6. create a function to check person is available in the queue
7. create a function to run application
a. call a function to display message
b. call a function to user details
c. call a function to validate voters age
d. call a function to ask where any person available in queue
if yes
continue the application
else
call a function to display thank you message and exit the application
"""
# 1. create function to display welcome message
def welcome_message():
print("Welcome to voting validation application")
# 2. create function to display user message
def display_message():
print("Enter user details to check voters age validity:\n")
# 3. create a function to take user details
def get_user_details():
name = input("Enter user name:\n")
age = int(input("Enter user age:\n"))
return name, age
# 4. create a function to validate the age for voting
def validate_voting(age):
return age >= 18
# 6. create a function to check person is available in the queue
def person_available():
print("Is there any more person present in the queue")
return input("\t if yes press y\n") == "y"
# 5. create a function to display a thank you
def say_thank_you():
print("Thank you for using our voter application visit us next time")
# 7. create a function to run application
def run_application():
let_run = True
while let_run:
display_message()
name, age = get_user_details()
eligible = validate_voting(age)
if eligible:
print(f"Hi {name}, you are eligible to vote")
else:
print(f"Hi {name}, you are not eligible to vote, since your age is below 18")
let_run = person_available()
say_thank_you()
run_application()