-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.py
More file actions
100 lines (84 loc) · 3.25 KB
/
Copy pathProject.py
File metadata and controls
100 lines (84 loc) · 3.25 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
#Projects-
# Guess Game
secret_word="Baka"
guess=""
Chances = ""
for Chances in range(1,4):
guess = input("Enter A Word:")
if guess == secret_word:
print("You Won!")
break
elif Chances == 3:
print("Chances Over.Better Luck Next Time.")
elif guess != secret_word:
print("Try Again.")
else:
break
#Translator
#Q- Create a translator that will convert the vowels present inside a word into "g".
def translator():
vowels=["a","e","i","o","u","A","E","I","O","U"]
word=str(input("Enter a word: "))
for character in word: #This line check for the character in the word.
if character in vowels: #This line check for vowel present in the word.
updated_word=word.replace(character,"g") # This word replace the vowel with "g".
print(updated_word)
break #break the code after it succesfull completion
else:
print ("Word does not contain any vowels.")
translator()
# Multiple Choice Question Quiz
import random
Questions = [
"Q- What we use to read a file in Python?\n a.w b. r+ c.r",
"Q- In which year Python was implemented?\n a.1980 b.1989 c. 1987",
"Q- Who created Python?\n a.Guido Van Rossum b.Brendan Eich c.James Gosling"
]
class Logic:
def __init__(self,q):
self.q=q
i = 0
remaining =Questions.copy()
while i < len(Questions):
q=random.choice(remaining)
print(q)
if(q == "Q- What we use to read a file in Python?\n a.w b. r+ c.r"):
user=str(input(""))
ans = "c"
if (i == len(Questions)-1) and user == ans:
print ("Correct Answer.Quiz Ended")
elif(i == len(Questions)-1) and user!= ans:
print("Wrong Answer.Quiz Ended.")
elif user == ans:
print("Correct Answer.Moving to next question.")
else:
print("Wrong Answer.Check other questions.")
elif (q == "Q- In which year Python was implemented?\n a.1980 b.1989 c. 1987" ):
user2=str(input(""))
ans2 ="b"
if (i == len(Questions)-1) and user2 == ans2:
print ("Correct Answer.Quiz Ended")
elif(i == len(Questions)-1) and user2 != ans2:
print("Wrong Answer.Quiz Ended.")
elif user2 == ans2 :
print("Correct Answer.Moving to next question")
else:
print("Wrong Answer.Check other questions")
elif (q == "Q- Who created Python?\n a.Guido Van Rossum b.Brendan Eich c.James Gosling"):
user3=str(input(""))
ans3 = "a"
if (i == len(Questions)-1) and user3 == ans3:
print ("Correct Answer.Quiz Ended")
elif(i == len(Questions)-1) and user3 != ans3:
print("Wrong Answer.Quiz Ended.")
elif user3 == ans3:
print("Correct Answer.Moving to next question.")
else:
print("Wrong Answer.Check other questions")
else:
print("There was an error starting the Logic.")
remaining.remove(q)
i+=1
if i == len(Questions):
break
Logic("q")