-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg3.py
More file actions
74 lines (57 loc) · 3.35 KB
/
Prog3.py
File metadata and controls
74 lines (57 loc) · 3.35 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
69
70
71
72
73
74
# Loops and If conditions project
# 11 November 2021
# Version 1.1
# Wayne Caissie
border_amount = 30
famous_ladies = "madonna cher kerrigan".split()
name_first = "Wayne" #Author's first and last names added as variables
name_last = "Caissie" #to check name_first against user_name later
password = "hello"
program_title = "Loops and if conditions project"
def main():
""" The purpose of this program is to demonstrate Python's looping and
conditionals for branching inside a program."""
student_info()
print("""Welcome, this program will only allow program access to users who
can demonstrate that they know the super duper secret password.""")
choice() #Start the flow of control
def second_half():
user_name = input("What is your first name? >>> ") #Ask for the user's name
if user_name.lower() in famous_ladies: #Check if an esteemed lady, if so ask
print("CAN I GET YOUR AUTOGRAPH MA'AM!?") #For their autograph
elif user_name.lower() == name_first.lower(): #If user's first name is same as project
print("What a great name!") #maker, compliment them
else:
print("{}, that's a nice name.".format(user_name.capitalize())) #Otherwise give a generic response
def begin():
password_attempt = input("What is the password? >>> ") #Check if user knows the password
if password_attempt == password:
print("\nWelcome to the second part of the program, human!") #If possible to pass the check, send
second_half() #the user to the next half of the program
else:
print("That is not a correct password!")
choice()
def goodbye():
print("Goodbye! See you next time.")
def choice():
user_choice = "unknown" #Checks for willingness to participate
while user_choice == "unknown":
user_choice = input("\nDo you wish to continue? (y/n) >>> ").lower()
if user_choice == "y" or user_choice == "yes":
begin()
elif user_choice == "n" or user_choice == "no":
goodbye()
else:
user_choice = "unknown"
print("You must select y for yes or n for no.")
def student_info(): #Project information for professor
"""This function will print out the particulars for the project start."""
print("\n")
print("#" * border_amount)
print("\nProgram_Author:", name_first, name_last)
print("Student ID number : 3558688")
print("Program title:", program_title, "\n")
print("#" * border_amount)
print("\n")
if __name__ == "__main__": #Checks if file was imported or is main
main()