Skip to content

Commit 1c03f56

Browse files
committed
Ml Models
1 parent 76e2f4e commit 1c03f56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+383
-705
lines changed

Project 04/.idea/Project 04.iml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Quiz App GUI Day 34/.idea/workspace.xml

Lines changed: 0 additions & 161 deletions
This file was deleted.
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import json
2-
3-
from difflib import get_close_matches
4-
5-
6-
data=json.load(open("data.json"))
7-
8-
def dictionary(word):
9-
if word in data:
10-
return data[word]
11-
12-
elif word.title() in data:
13-
return data[word.title()]
14-
15-
elif word.upper() in data:
16-
return data[word.upper()]
17-
18-
elif word.lower() in data:
19-
return data[word.lower()]
20-
21-
elif len(get_close_matches(word , data.keys())) > 0:
22-
print("did you mean %s insteads" %get_close_matches(word,data.keys())[0])
23-
MATCH=input("enter y for and n for no : ")
24-
25-
if MATCH== "y":
26-
return data[get_close_matches(word,data.keys())[0]]
27-
28-
elif MATCH=="n":
29-
print("this word is not avail dictionary.")
30-
31-
else:
32-
print("you input not match to y or n.")
33-
34-
35-
else:
36-
print("this word is not avail in dictionary.")
37-
38-
39-
word=input("Enter the word : ")
40-
p=dictionary(word)
41-
42-
if type(p) == list:
43-
for item in p:
44-
print(item)
45-
else:
1+
import json
2+
3+
from difflib import get_close_matches
4+
5+
6+
data=json.load(open("data.json"))
7+
8+
def dictionary(word):
9+
if word in data:
10+
return data[word]
11+
12+
elif word.title() in data:
13+
return data[word.title()]
14+
15+
elif word.upper() in data:
16+
return data[word.upper()]
17+
18+
elif word.lower() in data:
19+
return data[word.lower()]
20+
21+
elif len(get_close_matches(word , data.keys())) > 0:
22+
print("did you mean %s insteads" %get_close_matches(word,data.keys())[0])
23+
MATCH=input("enter y for and n for no : ")
24+
25+
if MATCH== "y":
26+
return data[get_close_matches(word,data.keys())[0]]
27+
28+
elif MATCH=="n":
29+
print("this word is not avail dictionary.")
30+
31+
else:
32+
print("you input not match to y or n.")
33+
34+
35+
else:
36+
print("this word is not avail in dictionary.")
37+
38+
39+
word=input("Enter the word : ")
40+
p=dictionary(word)
41+
42+
if type(p) == list:
43+
for item in p:
44+
print(item)
45+
else:
4646
print(p)
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import json
2-
def dictionary():
3-
4-
data=json.load(open("data.json"))
5-
6-
x=input("Enter the word : ")
7-
8-
v=x.lower()
9-
if v in data:
10-
return data[v]
11-
else:
12-
print("this word is not available")
13-
return dictionary()
14-
print(data[v])
1+
import json
2+
def dictionary():
3+
4+
data=json.load(open("data.json"))
5+
6+
x=input("Enter the word : ")
7+
8+
v=x.lower()
9+
if v in data:
10+
return data[v]
11+
else:
12+
print("this word is not available")
13+
return dictionary()
14+
print(data[v])
1515
dictionary()
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
from question_model import Question
2-
from data import question_data
3-
from quiz_brain import QuizBrain
4-
question_bank = []
5-
6-
for question in question_data:
7-
question_text = question["text"]
8-
question_answer = question["answer"]
9-
new_question = Question(question_text, question_answer)
10-
question_bank.append(new_question)
11-
12-
quiz = QuizBrain(question_bank)
13-
14-
while quiz.is_still_question:
15-
16-
quiz.next_question()
17-
18-
19-
1+
from question_model import Question
2+
from data import question_data
3+
from quiz_brain import QuizBrain
4+
question_bank = []
5+
6+
for question in question_data:
7+
question_text = question["text"]
8+
question_answer = question["answer"]
9+
new_question = Question(question_text, question_answer)
10+
question_bank.append(new_question)
11+
12+
quiz = QuizBrain(question_bank)
13+
14+
while quiz.is_still_question:
15+
16+
quiz.next_question()
17+
18+
19+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Question:
2-
def __init__(self, text, answer):
3-
self.text = text
4-
self.answer = answer
1+
class Question:
2+
def __init__(self, text, answer):
3+
self.text = text
4+
self.answer = answer
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
class QuizBrain:
2-
def __init__(self, q_list):
3-
self.question_number = 0
4-
self.score=0
5-
self.question_list = q_list
6-
7-
def is_still_question(self):
8-
return len(self.question_list) > self.question_number
9-
10-
def next_question(self):
11-
current_question = self.question_list[self.question_number]
12-
self.question_number += 1
13-
a = input(f"q.{self.question_number}:{current_question.text} (True/False): ")
14-
15-
if a == current_question.answer:
16-
print("You got it right!")
17-
print(f"The correct answer is {current_question.answer}")
18-
self.score+= 1
19-
print(f"{self.score}")
20-
21-
22-
else:
23-
print("No you don't got it :")
24-
print(f"The correct answer is {current_question.answer}")
25-
1+
class QuizBrain:
2+
def __init__(self, q_list):
3+
self.question_number = 0
4+
self.score=0
5+
self.question_list = q_list
6+
7+
def is_still_question(self):
8+
return len(self.question_list) > self.question_number
9+
10+
def next_question(self):
11+
current_question = self.question_list[self.question_number]
12+
self.question_number += 1
13+
a = input(f"q.{self.question_number}:{current_question.text} (True/False): ")
14+
15+
if a == current_question.answer:
16+
print("You got it right!")
17+
print(f"The correct answer is {current_question.answer}")
18+
self.score+= 1
19+
print(f"{self.score}")
20+
21+
22+
else:
23+
print("No you don't got it :")
24+
print(f"The correct answer is {current_question.answer}")
25+

0 commit comments

Comments
 (0)