Fixed Error

This commit is contained in:
Arcron ArchLinux 2024-10-29 17:59:34 +05:30
parent fbec4854e3
commit 4d3a07e207
64 changed files with 993 additions and 0 deletions

View File

@ -0,0 +1,78 @@
import tkinter as tk
from tkinter import *
import tk
from tkinter import messagebox
import pyperclip
from random import choice, randint, shuffle
# ---------------------------- PASSWORD GENERATOR ------------------------------- #
#Password Generator Project
def generate_password():
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
password_letters = [choice(letters) for _ in range(randint(8, 10))]
password_symbols = [choice(symbols) for _ in range(randint(2, 4))]
password_numbers = [choice(numbers) for _ in range(randint(2, 4))]
password_list = password_letters + password_symbols + password_numbers
shuffle(password_list)
password = "".join(password_list)
password_entry.insert(0, password)
pyperclip.copy(password)
# ---------------------------- SAVE PASSWORD ------------------------------- #
def save():
website = website_entry.get()
email = email_entry.get()
password = password_entry.get()
if len(website) == 0 or len(password) == 0 or len(email) == 0:
messagebox.showinfo(title="Oops!", message="Please make sure you haven't left any fields empty.")
else:
is_ok = messagebox.askyesno(title=website, message=f"These are the details entered: \nEmail: {email} "
f"\nPassword: {password} \n")
if is_ok:
with open("data.txt", "a") as data_file:
data_file.write(f"{website} | {email} | {password}\n")
website_entry.delete(0, END)
password_entry.delete(0, END)
email_entry.delete(0, END)
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Password Manager")
window.config(padx=50, pady=50)
canvas = Canvas(height=200, width=200)
logo_img = PhotoImage(file="password_manager.png")
canvas.create_image(100, 100, image=logo_img)
canvas.grid(row=0, column=1)
#Labels
website_label = Label(text="Website:")
website_label.grid(row=1, column=0)
email_label = Label(text="Email/Username:")
email_label.grid(row=2, column=0)
password_label = Label(text="Password:")
password_label.grid(row=3, column=0)
#Entries
website_entry = Entry(width=49)
website_entry.grid(row=1, column=1, columnspan=2)
website_entry.focus()
email_entry = Entry(width=49)
email_entry.grid(row=2, column=1, columnspan=2)
password_entry = Entry(width=30)
password_entry.grid(row=3, column=1)
#Buttons
generate_password_button = Button(text="Generate Password", command=generate_password)
generate_password_button.grid(row=3, column=2)
add_button = Button(text="Add", width=46, command=save)
add_button.grid(row=4, column=1, columnspan=2)
window.mainloop()

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.12 (pythonProject1)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,14 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E302" />
<option value="E265" />
<option value="E303" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (pythonProject1)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/NATO-alphabet-start.iml" filepath="$PROJECT_DIR$/.idea/NATO-alphabet-start.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="10bb84f0-be72-48b1-9e29-d101169d3bec" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 2
}]]></component>
<component name="ProjectId" id="2guhlBEpOv4s5qsC1WpmlGzdHJc" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Python.main.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true"
}
}]]></component>
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-python-sdk-babbdf50b680-746f403e7f0c-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.15989.155" />
</set>
</attachedChunks>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="10bb84f0-be72-48b1-9e29-d101169d3bec" name="Changes" comment="" />
<created>1716553518691</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1716553518691</updated>
</task>
<servers />
</component>
<component name="UnknownFeatures">
<option featureType="com.intellij.fileTypeFactory" implementationName="*.csv" />
</component>
</project>

View File

@ -0,0 +1,17 @@
import pandas
data = pandas.read_csv("nato_phonetic_alphabet.csv")
phonetic_dict = {row.letter: row.code for (index, row) in data.iterrows()}
print(phonetic_dict)
def generate_phoenetic():
word = input("Enter a word: ").upper()
try:
output_list = [phonetic_dict[letter] for letter in word]
except KeyError:
print("Sorry, only letters in the alphabet, but you can type numbers in words to get the answer.")
generate_phoenetic()
else:
print(output_list)
generate_phoenetic()

View File

@ -0,0 +1,27 @@
letter,code
A,Alfa
B,Bravo
C,Charlie
D,Delta
E,Echo
F,Foxtrot
G,Golf
H,Hotel
I,India
J,Juliet
K,Kilo
L,Lima
M,Mike
N,November
O,Oscar
P,Papa
Q,Quebec
R,Romeo
S,Sierra
T,Tango
U,Uniform
V,Victor
W,Whiskey
X,X-ray
Y,Yankee
Z,Zulu
1 letter code
2 A Alfa
3 B Bravo
4 C Charlie
5 D Delta
6 E Echo
7 F Foxtrot
8 G Golf
9 H Hotel
10 I India
11 J Juliet
12 K Kilo
13 L Lima
14 M Mike
15 N November
16 O Oscar
17 P Papa
18 Q Quebec
19 R Romeo
20 S Sierra
21 T Tango
22 U Uniform
23 V Victor
24 W Whiskey
25 X X-ray
26 Y Yankee
27 Z Zulu

View File

@ -0,0 +1,3 @@
{
"CodeGPT.apiKey": "CodeGPT Enterprise"
}

View File

@ -0,0 +1,103 @@
French,English
partie,part
histoire,history
chercher,search
seulement,only
police,police
pensais,thought
aide,help
demande,request
genre,kind
mois,month
frère,brother
laisser,let
car,because
mettre,to put
aucun,no
laisse,leash
eux,them
ville,city
chaque,each
parlé,speak
arrivé,come
devrait,should
bébé,baby
longtemps,long time
heures,hours
vont,will
pendant,while
revoir,meet again
aucune,any
place,square
parle,speak
compris,understood
savais,knew
étaient,were
attention,Warning
voici,here is
pourrais,could
affaire,case
donner,give
type,type
leurs,their
donné,given
train,train
corps,body
endroit,place
yeux,eyes
façon,way
écoute,listen
dont,whose
trouve,find
premier,first
perdu,lost
main,hand
première,first
côté,side
pouvoir,power
vieux,old
sois,be
tiens,here
matin,morning
tellement,so much
enfant,child
point,point
venu,came
suite,after
pardon,sorry
venez,come
devant,in front of
vers,towards
minutes,minutes
demandé,request
chambre,bedroom
mis,placed
belle,beautiful
droit,law
aimerais,would like to
aujourd'hui,today
mari,husband
cause,cause
enfin,finally
espère,hope
eau,water
attendez,Wait
parti,left
nouvelle,new
boulot,job
arrêter,Stop
dirait,would say
terre,Earth
compte,account
donne,given
loin,far
fin,end
croire,believe
chérie,sweetheart
gros,large
plutôt,rather
aura,will have
filles,girls
jouer,to play
bureau,officepart
histoire,history
1 French English
2 partie part
3 histoire history
4 chercher search
5 seulement only
6 police police
7 pensais thought
8 aide help
9 demande request
10 genre kind
11 mois month
12 frère brother
13 laisser let
14 car because
15 mettre to put
16 aucun no
17 laisse leash
18 eux them
19 ville city
20 chaque each
21 parlé speak
22 arrivé come
23 devrait should
24 bébé baby
25 longtemps long time
26 heures hours
27 vont will
28 pendant while
29 revoir meet again
30 aucune any
31 place square
32 parle speak
33 compris understood
34 savais knew
35 étaient were
36 attention Warning
37 voici here is
38 pourrais could
39 affaire case
40 donner give
41 type type
42 leurs their
43 donné given
44 train train
45 corps body
46 endroit place
47 yeux eyes
48 façon way
49 écoute listen
50 dont whose
51 trouve find
52 premier first
53 perdu lost
54 main hand
55 première first
56 côté side
57 pouvoir power
58 vieux old
59 sois be
60 tiens here
61 matin morning
62 tellement so much
63 enfant child
64 point point
65 venu came
66 suite after
67 pardon sorry
68 venez come
69 devant in front of
70 vers towards
71 minutes minutes
72 demandé request
73 chambre bedroom
74 mis placed
75 belle beautiful
76 droit law
77 aimerais would like to
78 aujourd'hui today
79 mari husband
80 cause cause
81 enfin finally
82 espère hope
83 eau water
84 attendez Wait
85 parti left
86 nouvelle new
87 boulot job
88 arrêter Stop
89 dirait would say
90 terre Earth
91 compte account
92 donne given
93 loin far
94 fin end
95 croire believe
96 chérie sweetheart
97 gros large
98 plutôt rather
99 aura will have
100 filles girls
101 jouer to play
102 bureau officepart
103 histoire history

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,68 @@
from tkinter import *
import pandas
import random
BACKGROUND_COLOR = "#B1DDC6"
current_card = {}
to_learn = {}
#############################################################------FUNCTIONS------##########################################################################
try:
data = pandas.read_csv("data/words_to_learn.csv")
except FileNotFoundError:
original_data = pandas.read_csv("data/french_words.csv")
to_learn = original_data.to_dict(orient="records")
else:
to_learn = data.to_dict(orient="records")
def next_card():
global current_card, flip_timer
window.after_cancel(flip_timer)
current_card = random.choice(to_learn)
canvas.itemconfig(card_title, text="French", fill="black")
canvas.itemconfig(card_word, text=current_card["French"], fill="black")
canvas.itemconfig(card_background, image=card_front_img)
flip_timer = window.after(5000, func=flip_card)
def flip_card():
canvas.itemconfig(card_title, text="English", fill="white")
canvas.itemconfig(card_word, text=current_card["English"], fill="white")
canvas.itemconfig(card_background, image=card_back_img)
def is_known():
to_learn.remove(current_card)
data = pandas.DataFrame(to_learn)
data.to_csv("data/words_to_learn", index=False)
next_card()
#############################################################------WINDOWS------##########################################################################
window = Tk()
window.title("Flashy")
window.config(padx=50, pady=50, bg=BACKGROUND_COLOR)
flip_timer = window.after(5000, func=flip_card)
canvas = Canvas(width=800, height=526)
card_front_img = PhotoImage(file="images/card_front.png")
card_back_img = PhotoImage(file="images/card_back.png")
card_background = canvas.create_image(400, 263, image=card_front_img)
card_title = canvas.create_text(400, 150, text="", font=("Ariel", 40, "italic"))
card_word = canvas.create_text(400, 263, text="", font=("Ariel", 40, "bold"))
canvas.config(bg=BACKGROUND_COLOR, highlightthickness=0)
canvas.grid(row=0, column=0, columnspan=2)
#############################################################------BUTTONS------##########################################################################
cross_image = PhotoImage(file="images/wrong.png")
unknown_button = Button(image=cross_image, highlightthickness=0, command=next_card)
unknown_button.grid(row=1, column=0)
check_image = PhotoImage(file="images/right.png")
known_button = Button(image=check_image, highlightthickness=0, command=is_known)
known_button.grid(row=1, column=1)
next_card()
window.mainloop()

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,30 @@
from tkinter import *
import requests
def get_quote():
response = requests.get("https://api.kanye.rest")
response.raise_for_status()
data = response.json()
quote = data["quote"]
canvas.itemconfig(quote_text, text=quote)
window = Tk()
window.title("Kanye Says...")
window.config(padx=50, pady=50)
canvas = Canvas(width=300, height=414)
background_img = PhotoImage(file="Visual_Studio_Code_Projects/Kanye-quotes-start/background.png")
canvas.create_image(150, 207, image=background_img)
quote_text = canvas.create_text(150, 207, text="Kanye Quote Goes Here", width=250, font=("Arial", 15, "bold"), fill="white")
canvas.grid(row=0, column=0)
kanye_img = PhotoImage(file="kanye.png")
kanye_button = Button(image=kanye_img, highlightthickness=0, command=get_quote)
kanye_button.grid(row=1, column=0)
window.mainloop()

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,21 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E302" />
<option value="E265" />
<option value="E303" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredNames">
<list>
<option value="input" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.8" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pomodoro-start.iml" filepath="$PROJECT_DIR$/.idea/pomodoro-start.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,87 @@
from tkinter import *
import math
# ---------------------------- CONSTANTS ------------------------------- #
PINK = "#e2979c"
RED = "#e7305b"
GREEN = "#9bdeac"
YELLOW = "#f7f5dd"
FONT_NAME = "Courier"
WORK_MIN = 25
SHORT_BREAK_MIN = 5
LONG_BREAK_MIN = 20
reps = 0
timer = None
# ---------------------------- TIMER RESET ------------------------------- #
def reset_timer():
window.after_cancel(timer)
canvas.itemconfig(timer_text, text="00:00")
title_label.config(text="Timer")
check_marks.config(text="")
global reps
reps = 0
# ---------------------------- TIMER MECHANISM ------------------------------- #
def start_timer():
global reps
reps += 1
work_sec = WORK_MIN * 60
short_break_sec = SHORT_BREAK_MIN * 60
long_break_sec = LONG_BREAK_MIN * 60
if reps % 8 == 0:
count_down(long_break_sec)
title_label.config(text="Break", fg=RED)
elif reps % 2 == 0:
count_down(short_break_sec)
title_label.config(text="Break", fg=PINK)
else:
count_down(work_sec)
title_label.config(text="Work", fg=GREEN)
# ---------------------------- COUNTDOWN MECHANISM ------------------------------- #
def count_down(count):
count_min = math.floor(count / 60)
count_sec = count % 60
if count_sec < 10:
count_sec = f"0{count_sec}"
canvas.itemconfig(timer_text, text=f"{count_min}:{count_sec}")
if count > 0:
global timer
timer = window.after(1000, count_down, count - 1)
else:
start_timer()
marks = ""
work_sessions = math.floor(reps/2)
for _ in range(work_sessions):
marks += ""
check_marks.config(text=marks)
# ---------------------------- UI SETUP ------------------------------- #
window = Tk()
window.title("Pomodoro")
window.config(padx=100, pady=50, bg=YELLOW)
title_label = Label(text="Timer", fg=GREEN, bg=YELLOW, font=(FONT_NAME, 50))
title_label.grid(column=1, row=0)
canvas = Canvas(width=200, height=224, bg=YELLOW, highlightthickness=0)
tomato_img = PhotoImage(file="tomato.png")
canvas.create_image(100, 112, image=tomato_img)
timer_text = canvas.create_text(100, 130, text="00:00", fill="white", font=(FONT_NAME, 29, "bold"))
canvas.grid(column=1, row=1)
start_button = Button(text="Start", highlightthickness=0, command=start_timer)
start_button.grid(column=0, row=2)
reset_button = Button(text="Reset", highlightthickness=0, command=reset_timer)
reset_button.grid(column=2, row=2)
check_marks = Label(fg=GREEN, bg=YELLOW, font=(FONT_NAME, 15))
check_marks.grid(column=1, row=3)
window.mainloop()

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,21 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E302" />
<option value="E265" />
<option value="E303" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredNames">
<list>
<option value="input" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (pythonProject1)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/quizzler-app-start.iml" filepath="$PROJECT_DIR$/.idea/quizzler-app-start.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.12 (pythonProject1)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,12 @@
import requests
parameters = {
"amount": 10,
"type": "boolean",
"category": ""
}
response = requests.get("https://opentdb.com/api.php?amount=20&type=boolean", params=parameters)
response.raise_for_status()
data = response.json()
question_data = data["results"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,21 @@
from question_model import Question
from data import question_data
from quiz_brain import QuizBrain
from ui import QuizInterface
question_bank = []
for question in question_data:
question_text = question["question"]
question_answer = question["correct_answer"]
new_question = Question(question_text, question_answer)
question_bank.append(new_question)
quiz = QuizBrain(question_bank)
quiz_ui = QuizInterface(quiz)
# while quiz.still_has_questions():
# quiz.next_question()
print("You've completed the quiz")
print(f"Your final score was: {quiz.score}/{quiz.question_number}")

View File

@ -0,0 +1,5 @@
class Question:
def __init__(self, q_text, q_answer):
self.text = q_text
self.answer = q_answer

View File

@ -0,0 +1,30 @@
import html
class QuizBrain:
def __init__(self, q_list):
self.question_number = 0
self.score = 0
self.question_list = q_list
self.current_question = None
def still_has_questions(self):
return self.question_number < len(self.question_list)
def next_question(self):
self.current_question = self.question_list[self.question_number]
self.question_number += 1
q_text = html.unescape(self.current_question.text)
return f"Q.{self.question_number}: {q_text} True or False: "
# user_answer = input(f"Q.{self.question_number}: {self.current_question.text} (True/False): ")
# self.check_answer(user_answer)
def check_answer(self, user_answer):
correct_answer = self.current_question.answer
if user_answer.lower() == correct_answer.lower():
self.score += 1
return True
else:
return False
print(f"Your current score is: {self.score}/{self.question_number}")
print("\n")

View File

@ -0,0 +1,70 @@
from tkinter import *
from quiz_brain import QuizBrain
THEME_COLOR = "#375362"
class QuizInterface:
def __init__(self, quiz_brain: QuizBrain):
self.quiz = quiz_brain
self.window = Tk()
self.window.title("Quizzler")
self.window.config(padx=40, pady=40, bg=THEME_COLOR)
self.score_label = Label(text="Score: 0",
fg="white",
bg=THEME_COLOR,
font=("Times", 18, "bold")
)
self.score_label.grid(row=0, column=1)
self.canvas = Canvas(width=300, height=250, bg="white")
self.question_text = self.canvas.create_text(
150,
125,
width=280,
text="Some Question Text",
fill='black',
font=("Times", 20, "bold")
)
self.canvas.grid(row=1, column=0, columnspan=2, pady=50, padx=30)
true_image = PhotoImage(file="images/true.png")
false_image = PhotoImage(file="images/false.png")
self.true_button = Button(image=true_image, highlightthickness=0, bg=THEME_COLOR, fg=THEME_COLOR, command=self.true_pressed)
self.false_button = Button(image=false_image, highlightthickness=0, bg=THEME_COLOR, fg=THEME_COLOR, command=self.false_pressed)
self.true_button.grid(row=2, column=1)
self.false_button.grid(row=2, column=0)
self.get_next_question()
self.window.mainloop()
def get_next_question(self):
self.canvas.config(bg="white")
if self.quiz.still_has_questions():
self.score_label.config(text=f"Score: {self.quiz.score}")
q_text = self.quiz.next_question()
self.canvas.itemconfig(self.question_text, text=q_text)
else:
self.canvas.itemconfig(self.question_text, text="Hey looks like you were enjoying the quiz but I am sorry"
" to inform you that we have ran out of questions")
self.true_button.config(state="disabled")
self.false_button.config(state="disabled")
def true_pressed(self):
self.give_feedback(self.quiz.check_answer("True"))
def false_pressed(self):
is_right = self.quiz.check_answer("False")
self.give_feedback((is_right))
def give_feedback(self, is_right):
if is_right:
self.canvas.config(bg="lime green")
else:
self.canvas.config(bg="red")
self.window.after(1000, self.get_next_question)

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,14 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E302" />
<option value="E265" />
<option value="E303" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.8" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (pythonProject1)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/turtle-crossing-start.iml" filepath="$PROJECT_DIR$/.idea/turtle-crossing-start.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.12 (pythonProject1)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1 @@
print("")

View File

@ -0,0 +1,28 @@
from turtle import Turtle
t = Turtle()
t.penup()
t.goto(0, 0)
def draw_square(size, color):
t.pendown()
t.color(color)
for x in range(4):
t.forward(size)
t.right(90)
t.penup()
def draw_circle(size, color):
t.pendown()
t.color(color)
for x in range(36):
t.forward(size)
t.right(10)
t.penup()
while True:
t.speed(100)
draw_square(100, "red")
draw_circle(20, "blue")
t.right(10)

View File

@ -0,0 +1,31 @@
from turtle import Turtle
import random
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
STARTING_MOVE_DISTANCE = 5
MOVE_INCREMENT = 10
class CarManager:
def __init__(self):
self.all_cars = []
self.car_speed = STARTING_MOVE_DISTANCE
def create_car(self):
random_chance = random.randint(1, 6)
if random_chance == 1:
new_car = Turtle("square")
new_car.shapesize(stretch_wid=1, stretch_len=2)
new_car.penup()
new_car.color(random.choice(COLORS))
random_y = random.randint(-400, 400)
new_car.goto(1000, random_y)
self.all_cars.append(new_car)
def move_cars(self):
for car in self.all_cars:
car.backward(self.car_speed)
def level_up(self):
self.car_speed += MOVE_INCREMENT

View File

@ -0,0 +1,39 @@
import time
from turtle import Screen
from player import Player
from car_manager import CarManager
from scoreboard import Scoreboard
screen = Screen()
screen.setup(width=2000, height=1000)
screen.tracer(0)
player = Player()
car_manager = CarManager()
scoreboard = Scoreboard()
screen.listen()
screen.onkey(player.go_up, "Up")
game_is_on = True
while game_is_on:
time.sleep(0.1)
screen.update()
car_manager.create_car()
car_manager.move_cars()
#Detect collision with car
for car in car_manager.all_cars:
if car.distance(player) < 20:
game_is_on = False
scoreboard.game_over()
#Detect successful crossing
if player.is_at_finish_line():
player.go_to_start()
car_manager.level_up()
scoreboard.increase_level()
screen.exitonclick()

View File

@ -0,0 +1,27 @@
from turtle import Turtle
STARTING_POSITION = (0, -450)
MOVE_DISTANCE = 10
FINISH_LINE_Y = 490
class Player(Turtle):
def __init__(self):
super().__init__()
self.shape("turtle")
self.penup()
self.color("turquoise")
self.go_to_start()
self.setheading(90)
def go_up(self):
self.forward(MOVE_DISTANCE)
def go_to_start(self):
self.goto(STARTING_POSITION)
def is_at_finish_line(self):
if self.ycor() > FINISH_LINE_Y:
return True
else:
return False

View File

@ -0,0 +1,26 @@
from turtle import Turtle
FONT = ("Courier", 24, "normal")
class Scoreboard(Turtle):
def __init__(self):
super().__init__()
self.level = 1
self.hideturtle()
self.penup()
self.goto(-950, 450)
self.update_scoreboard()
def update_scoreboard(self):
self.clear()
self.write(f"Level: {self.level}", align="left", font=FONT)
def increase_level(self):
self.level += 1
self.update_scoreboard()
def game_over(self):
self.goto(0, 0)
self.write("GAME OVER ", align="center", font=FONT)

View File

@ -0,0 +1,47 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 26 15:31:48 2024
@author: sameer
"""
#Program for converting a number entered as word into integer
#Another option is to use word2number library
def words_to_number(words):
num_words = {
"zero": 0, "one": 1, "two": 2, "three": 3, "four": 4,
"five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9,
"ten": 10, "eleven": 11, "twelve": 12, "thirteen": 13,
"fourteen": 14, "fifteen": 15, "sixteen": 16, "seventeen": 17,
"eighteen": 18, "nineteen": 19, "twenty": 20, "thirty": 30,
"forty": 40, "fifty": 50, "sixty": 60, "seventy": 70,
"eighty": 80, "ninety": 90, "hundred": 100, "thousand": 1000
}
words = words.lower().split()
total = 0
current = 0
for word in words:
if word in num_words:
scale = num_words[word]
if scale == 100:
current *= scale
elif scale == 1000:
current *= scale
total += current
current = 0
else:
current += scale
else:
raise ValueError(f"Word '{word}' is not a valid number")
return total + current
# Example usage
while words_to_number.words:
user = input("guess a number: ")
print(words_to_number(user))