-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject2.py
More file actions
170 lines (137 loc) · 4.33 KB
/
project2.py
File metadata and controls
170 lines (137 loc) · 4.33 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
max_attempts = 5
correct_username = "david"
for attempt in range(max_attempts):
username = input("Enter your username: ")
if(username == correct_username):
print("Welcome to my platform")
break
else:
print("Incorrect Username")
#Creating a user login system using While Loop
Max_attempts = 3
correct_username = "admin"
correct_password = "12345"
attempts = 1
username = input("Enter your username")
password = input("Enter your password")
while attempts < Max_attempts:
if(username == correct_username and password == correct_password):
break
else:
print("incorrect username or password")
username = input("Enter your username")
password = input("Enter your password")
attempts = attempts + 1
print(f"your number of attempts is { attempts}")
#Creating a user login system using If Loop
Max_attempts = 3
correct_username = "admin"
correct_password = "12345"
for attempt in range( Max_attempts):
username = input("Enter your usrename:")
password = input("Enter your password:")
if( username == correct_username and password == correct_password):
print("login successful")
breakEnter your usrename:admin
else:
print("incorrect username or password")#Creating a Result Application
correct_username = "uche"
correct_password = "ovanjohn"
username = input("Enter your username")
password = input("Enter your password")
if(username == correct_username and password == correct_password):
print(f"welcome to our grading app {username}")
no_total_scores = int(input("How many score do you want to input"))
masterList = []
start = 0
while(start < no_total_scores):
score = int(input("Enter your score"))
if(score >= 70 and score <= 100):
masterList.append("A")
elif(score >= 60 and score <= 69):
masterList.append("B")
elif(score >= 50 and score <= 59):
masterList.append("C")
else:
masterList.append("Fail")
#increment
start = start + 1
else:
print("Your username or password is worng")
print(masterList)
#Creating a Result App using for loop
correct_username = "uche"
correct_password = "chid"
#Request username and password
username = input("Enter your username:")
password = input("Enter your password:")
if(username == correct_username and password == correct_password):
print(f"Welcome to our App {username}")
no_of_score = int(input("Enter the number of score you want to input"))
masterList = []
for i in range( no_of_score):
score = int(input("Enter your score"))
if(score >= 70 and score <= 100):
masterList.append("A")
elif(score >= 60 and score <= 69):
masterList.append("B")
elif( score >= 50 and score <= 50):
masterList.append("C")
else:
masterList.append("Fail")
print(masterList)
#Greeting
def morningGreeting():
print("Good morning to you")
morningGreeting()
def dayGreetingAndTime( greetings, time):
print(f"Good Morning to you {greetings}, the time is {time} 9am")
greetings = input("Enter your greeting?")
time = input("Enter the time")
dayGreetingAndTime(greetings, time)
# 1. create a guessing where the user inputs a number and the program tells if the number is correct, too low or too high
import random
n = random.randrange(1, 10)
guess = int(input("Enter any number:"))
while n!= guess:
if guess < n:
print("Too low")
guess = int(input("Enter number:"))
elif guess > n:
print("Too high")
guess = int(input("Enter number:"))
else:
break
print("Correct")
#creating loop that print only odd number
number = int(input("Enter a number"))
for i in range(1, numbers +1):
if(i % 2 ==1):
print(i)
#creating loo that print only prime numbers
for num in range(1, 20):
for i in range(2, num):
if num % i == 0:
break
else:
print(num)
break
#loo to create square of numbers
numbers =[4, 2, 6, 7, 8]
square = 0
for value in numbers:
square = value **2
squares = square
print("The list of squares", square)
# A Voting Apllication Using Python
firstname = input("Enter your first name")
lastname = input("Enter your last name")
fullname = firstname +""+ lastname
print(f" welcome to our voting application {fullname}")
age = input("Enter your age ")
eligibleAge = 18
age = int(age)
if(age >= eligibleAge):
print(f" you are eligible to vote {fullname}")
else:
print("you are not eligible to vote")