Skip to content

Commit

Permalink
all
Browse files Browse the repository at this point in the history
  • Loading branch information
SyedaMairaSaad committed Dec 9, 2023
1 parent c222524 commit 196a333
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Identify_proper_or_common_noun.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Ali,,proper
children,,common
brother,,common
sister,,common
apple(fruit),,common
jobs,,common
babies,,common
parents,,common
clock tower,,proper
car,,common
proton saga,,proper
computer,,common
hp laptop,,proper
city,,common
karachi,,proper
scissors,,common
teacher,,common
shoes,,common
Miss Mehwish,,proper
pakistan,,proper
street,,common
boot,,common
alarm,,common
train,,common
sun,,proper
kitchen,,common
k-mart,,proper
pen,,common
air-blue,,proper
september,,proper
day,,common
window,,common
juice,,common
socks,,common
dog,,common
rufi green city,,proper
18 changes: 18 additions & 0 deletions PythonStackQuestion2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def display_top_scores(scores):
# Sort scores in descending order
sorted_scores = sorted(scores, reverse=True)

# Take the top 3 scores
top_scores = sorted_scores[:3]

# Display the top 3 scores in three different text fields
field1, field2, field3 = top_scores[:3]

# Printing for demonstration purposes; you can replace this with your actual GUI or text field update logic
print(f"Field 1: {field1}")
print(f"Field 2: {field2}")
print(f"Field 3: {field3}")

# Example usage with an array of scores
scores_array = [85, 92, 78, 95, 88, 90]
display_top_scores(scores_array)
10 changes: 10 additions & 0 deletions XMLParser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import xml.etree.ElementTree as ET
data='''<person>
<name>maira</name>
<telephone type="intl">+12345</telephone>
<email hide="Yes"/>
</person>'''

tree=ET.fromstring(data)
print("Name:",tree.find("name").text)
print("Email:",tree.find("email").get("hide"))
22 changes: 22 additions & 0 deletions XmlParser2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import xml.etree.ElementTree as ET
data='''<staff>
<users>
<user>
<name>Maira</name>
<telephone type="intl">+12345</telephone>
<email hide="Yes"/>
</user>
<user>
<name>Ali</name>
<telephone type="intl">+12346</telephone>
<email hide="No"/>
</user>
</users>
</staff>'''

xmlData=ET.fromstring(data)
dataTree=xmlData.findall("users/user")
print("Count:",len(dataTree))
for tree in dataTree:
print("Name:",tree.find("name").text)
print("Email:",tree.find("email").get("hide"))
11 changes: 11 additions & 0 deletions choose_correct_noun.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The student arrived safely.,,student
The building was very tall.,,building
Computer was broken.,,computer
The bell is so loud.,,bell
It will take all of your energy and will to be able to walk again.,Take-All-Your-Energy,energy
The works of many great poets have been placed on reserve.,Many-Great-Placed-Reserve,Reserve
The Brooklyn Bridge was opened in 1883.,Bridge-Was-Opened-in,bridge
Sharks and lampreys are not true fish because their skeletons are made of cartilage rather than bone.,True-Because-Their-Bone,bone
Have you met your new boss?',Have-Met-Your-Boss,Boss
Mastering basic mathematics is an important goal for younger students.,Mastering-Important-Younger-Students,students
Which of the following is a noun?,Book-Sing-Angry-Love,Book
56 changes: 56 additions & 0 deletions quiz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import random
from termcolor import colored
import os
os.system('color')
def quiz():
score=0
questionsRight=0
i=0
questionno=1
fnames=['choose_correct_noun.csv','Identify_proper_or_common_noun.csv','write_plural_of_the_following.csv']
for fname in fnames:
fileName =fname
f_name=fname.split('_')
s = ' '.join(f_name)
print(colored(s[:-4],'yellow'))
quizFile = open(fileName,"r")
quizData = quizFile.readlines()
random.shuffle(quizData)
i=i+len(quizData)

for i in range(len(quizData)):
x = quizData[i].strip()
data = x.split(",")
question = data[0]
choice=data[1]
CorrectAnswer = data[2]

print("Question #",questionno,question)
choice_list=choice.split('-')
k=len(choice_list)

for z in range(0,k):
if choice_list[z]!='':
print((z+1),'-',choice_list[z])

answer = input("What is your answer? ")
if answer.upper() == CorrectAnswer.upper():
print(colored("Correct!",'green'))
score=score+1
questionsRight=questionsRight+1
questionno = questionno+1

else:
print(colored("Incorrect.",'red'))
print(colored("Correct answer should be: "+CorrectAnswer,'blue'))
questionno = questionno+1


totalScore = (score / (questionno-1)) * 100
print(colored("You got "+str(score)+" questions right and a score of "+str(totalScore)+"%.",'yellow'))





quiz()
36 changes: 36 additions & 0 deletions write_plural_of_the_following.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
toy,,toys
pot,,pots
plate,,plates
dish,,dishes
spoon,,spoons
fork,,forks
box,,boxes
sandwich,,sandwiches
apple,,apples
orange,,oranges
horse,,horses
leaf,,leaves
child,,children
goose,,geese
deer,,deer
news,,news
sheep,,sheep
fungus,,fungi
man,,men
woman,,women
hoof,,hooves
candy,,candies
city,,cities
key,,keys
match,,matches
quiz,,quizzes
baby,,babies
wolf,,wolves
life,,lives
knife,,knives
foot,,feet
tooth,,teeth
mouse,,mice
person,,people
fish,,fish
series,,series

0 comments on commit 196a333

Please sign in to comment.