“Learning’s important, but ultimately it’s most important for people to get the chance to get the education that they need to succeed in the workforce and in life. ” – Gov. Scott Walker
I disagree with this quote. I would actually switch the other way round saying that learning is the most important thing. Gov. Scott Walker states that the way to succeed in life is to succeed in the workforce, however, I think succeeding in life cannot be a general quantification – it varies from person to person. Furthermore, I think that education is NOT preparing someone for entering the workforce, it’s all about learning as much as you can, to increase your own knowledge.
However, for some people, it can be all about money, in which case succeeding in the workforce would mean success in life. Money means being able to support a stable family and supplies some comfort. Personally, I want to learn as much as possible and do what I love, and the money will eventually follow.
Today in class, we started work on our project. Unfortunately, Ms. Mok, wasn’t here, therefore, we had a substitute. We began class by going down to the Middle School and talked to the PE department about how we could help them. Based on their information, we got into groups and decided to work together. Krish, Nick, Alex and I decided to form a group and work on improving the mile time.
We started with some planning on the whiteboard. Although it is a bit unclear, you can see it below.
We decided that on each of the splits, we would have RFID reader’s set up, which would be used in order to time the miles.
After a week, we had a working prototype. Here is the information on that.
Design Thinking Sentence:
Our PE department is having students run the mile in a slow and inefficient manner so we are creating a new system to time the mile taking account of splits using RFID cards to improve the student mile experience.
List of equipment needed:
RFID Scanner
RFID cards
Design Thinking Questionare:
Flow Chart:
Algorithm/Pseudo Code:
Import time
set a function for running with input of the RFID code
set five variables for five checkpoints (c1, c2, c3, c4, c5) and set them to zero
while c5 = 0
ask for input
if input is equal to RFID:
start two timers (startwhole and startone) using time.time()
c1=c1+1
……
ask for input
if input is equal to RFID:
c5=c5+1
while c5 = 1
….
ask for input
if input is equal to RFID:
get split one using (time.time()-startone)
set up another split timer (starttwo)
c2=c2+1
………
while c5=5
…….
ask for input
if input is equal to RFID:
get split four using (time.time()-startfour)
get whole mile time using (time.time()-startwhole)
Print time for Split 1-4 and whole mile
c5=c5+1
Actual Code:Screenshot Annotations:
mport serial, sys, time
import codecs
import time
import xlwt
style0 = xlwt.easyxf('font: name Times New Roman, color-index red, bold on',
num_format_str='#,##0.00')
style1 = xlwt.easyxf(num_format_str='D-MMM-YY')
#This is some imports that we need for the RFID sensors and recording the time
ard = None
def getCardId(rawCode):
headerStr = "1b390100110010603000"
#This is a top string used to call the scanner
returnId = -1
try:
decodestr = codecs.encode(rawCode, 'hex')
returnId = str(decodestr).split(headerStr)[1]
return returnId
except:
return -1
#This essesentially tells the sensor to look for a card. If it can't find one, then it return the value '-1'.
def initReader():
global ard
port = '/dev/tty.SLAB_USBtoUART'
ard = serial.Serial(port, baudrate=115200,timeout=5)
def readRfid():
global ard
rawCode = ard.read(24)
return getCardId(rawCode)
#This is a function that tells the sensor to look for a card.
def rfidInput():
while readRfid()==-1:
print("waiting...")
#When no RFID scanner is shown at the scanner, then the code prints waiting... to show that it is essentially waiting for us to put something.
else:
return readRfid()
def firstperson(RFID):
c1A=0
c2A=0
c3A=0
c4A=0
c5A=0
#Setting up checkpoints
while c5A<5.1:
#While loop that will run until c5A is greater than 5.1
global startone
global starttwo
global startthree
global startfour
global startwhole
#Setting up timer variables
while c5A==0:
#While loop that will run until c5A is not equal to zero
runningone=rfidInput()
if runningone==RFID:
startwhole=time.time()
startone=time.time()
#Sets up timer, time.time() is the amount of seconds since January 1, 1970
c1A+=1
print (RFID, "has started running.")
runningtwo=rfidInput()
if runningtwo==(RFID):
c2A+=1
print (RFID, "has completed the first 40 meters.")
#All of the smaller increments or checkpoints in general are when the runner passes the rfid scanners.
runningthree=rfidInput()
if runningthree==(RFID):
c3A+=1
print (RFID, "has passed the third checkpoint.")
runningfour=rfidInput()
if runningfour==(RFID):
c4A+=1
print (RFID, "has passed the fourth checkpoint.")
runningfive=rfidInput()
if runningfive==(RFID):
print(RFID, "has passed the fifth checkpoint.")
c5A+=1
#Basically everytime the checkpoint reads the certain RFID code, it notes it (this is the basic if statement that repeats itself throughout the entire code)
while c5A==1:
runningsix=rfidInput()
if runningsix==(RFID):
c1A+=1
print (RFID, "has passed the start line for the second time.")
runningseven=rfidInput()
if runningseven==(RFID):
c2A+=1
print(RFID, "has completed the first 400 meters.")
#Passing the first 400 meters in our code translates to running a single lap on a real 400 meter track.
s1=int(time.time()-startone)
#S1 is equal to the amount of seconds from startone to this point
starttwo=time.time()
#starts the second timer, rest of the code is repetition
runningeight=rfidInput()
if runningeight==(RFID):
c3A+=1
print (RFID, "has passed the third checkpoint for the second time.")
runningnine=rfidInput()
if runningnine==(RFID):
c4A+=1
print (RFID, "has passed the fourth checkpoint for the second time.")
running10=rfidInput()
if running10==(RFID):
print (RFID, "has passed the fifth checkpoint for the second time.")
c5A+=1
while c5A==2:
running11=rfidInput()
if running11==(RFID):
c1A+=1
print (RFID, "has passed the start line for the third time.")
running12=rfidInput()
if running12==(RFID):
c2A+=1
print(RFID, "has passed the second checkpoint for the third time.")
running13=rfidInput()
if running13==(RFID):
c3A+=1
print (RFID, "has completed 800 meters.")
s2=int(time.time()-starttwo)
startthree=time.time()
running14=rfidInput()
if running14==(RFID):
print (RFID, "has passed the fourth checkpoint for the third time.")
c4A+=1
running15=rfidInput()
if running15==(RFID):
print (RFID, "has passed the fifth checkpoint for the third time.")
c5A+=1
while c5A==3:
running16=rfidInput()
if running16==(RFID):
c1A+=1
print (RFID, "has passed the start line for the fourth time.")
running17=rfidInput()
if running17==(RFID):
c2A+=1
print(RFID, "has passed the second checkpoint for the fourth time.")
running18=rfidInput()
if running18==(RFID):
print (RFID, "has passed the third checkpoint for the fourth time.")
c3A+=1
running19=rfidInput()
if running19==(RFID):
c4A+=1
print (RFID, "has passed the fourth checkpoint for the fourth time.")
print (RFID, "has completed 1200 meters.")
s3=int(time.time()-startthree)
startfour=time.time()
running20=rfidInput()
if running20==(RFID):
print (RFID, "has passed the fifth checkpoint for the fourth time.")
c5A+=1
while c5A==4:
running21=rfidInput()
if running21==(RFID):
c1A+=1
print(RFID,"has passed the start line for the final time.")
running22=rfidInput()
if running22==(RFID):
c2A+=1
print(RFID,"has passed the second checkpoint for the final time.")
running23=rfidInput()
if running23==(RFID):
c3A+=1
print(RFID,"has passed the third checkpoint for the final time.")
running24=rfidInput()
if running24==(RFID):
c4A+=1
print(RFID,"has passed the fourth checkpoint for the final time.")
running25=rfidInput()
if running25==(RFID):
c5A+=1
print(RFID,"has completed the mile.")
s4=int(time.time()-startfour)
finaltime=int(time.time()-startwhole)
#record the total time to complete the mile
print("Split One:",s1, "Split Two:", s2, "Split Three:", s3, "Split Four:", s4,"Whole Mile:", finaltime)
#Prints the amount of time the person take to complete the mile, and the time for each split
c5A+=1
wb = xlwt.Workbook()
ws = wb.add_sheet('A Test Sheet')
vInfo = ("Split One:",s1, "Split Two:", s2, "Split Three:", s3, "Split Four:", s4,"Whole Mile:", finaltime)
vinput = input()
ws.write(0, 0, vInfo, style0)
wb.save('example.xls')
#Takes the amount of time the person take to complete the mile, and the time for each split and saves it into a worksheet called example.xls
break
initReader()
while readRfid()==-1:
print("waiting...")
#This is an infinite loop that records the RFID tag. Above, it prints 'waiting...' while there is no sensor that is being recognized. Below it runs the function readRfid(), which records the RFID card.
else:
rfid=readRfid()
firstperson(rfid)
Video of Working Prototype:
Testing Document:
Item
Test Outcome
Fixed
How fixed / Notes
Date
if
Passed
N/A
N/A
January 12th
while
Passed
N/A
N/A
January 12th
def
Passed
N/A
N/A
January 12th
import time
Passed
N/A
N/A
January 12th
global
Failed
Yes
Had to add it inside of the function as well as outside of the function
January 12th
input
Passed
N/A
N/A
January 12th
str
Passed
N/A
N/A
January 12th
print
Passed
N/A
N/A
January 12th
pygame timer
Failed
Yes
Got rid of pygame and replaced it with time.time() instead of the timer. Pygame timer didn’t work and crashed our computers on multiple occasions.
January 17th
class
Failed
No
N/A
January 19th
time.time()
Passed
N/A
Naturally worked without us having to open up a separate document.
January 19th
runningone – runningtwenty
Failed
Yes
There were repetition of variables, cleaned up the errors
January 19th
runningone – runningtwenty
Passed
N/A
N/A
January 19th
c1A-c5A
Passed
N/A
N/A
January 19th
firstperson()
Failed
Yes
Changed structure completely into five while loops with five separate inputs
January 12th
Evaluation:
For our final project, our goal was to help the PE teachers in timing the mile and after a week of hard work, we achieved that goal.
Intro to programming has been an extremely insightful, interesting and entertaining class. I have thoroughly enjoyed my time learning to code, and I hope to pure it in the near future. Under the fabulous leadership of the greatest teacher one could ask for, we, as a class, have learned a lot in these past few months. From the first lesson, where the only type of python we knew was a snake to now – where we are revolutionizing the current procedure of a long lasting PE school tradition. I have had a wonderful time programming.
print(“Goodnight world”)
References:
Stackoverflow
Mr. Lin – Hong Kong International School Technology Advisor
Youtube – ‘how to use import xlwt’
Teamwork:
Krish:
Helped write the code for the timer.
Helped a bit in merging the codes.
Accept Moral Support from Nic
Worked on the Testing Document
Sid:
Wrote Pseudo Code with Alex
Helped write the countdown code.
Researched about how to link up python with an external application – google sheets and excel.
Merged the RFID code (from Mr. Lin) with the Time and Count code from Krish/Nic.
Worked on Excel Sheet with Alex
Incorporated the knowledge from the excel sheet code into the final code.
Helped with the testing document.
With help from Mr. Lin, wrote the function rfidInput():
Worked on flowchart,
Alex:
Researched about how to link up python with an external application
Worked on Excel Sheet with Sid
Helped problem solve with Sid in the Code to find the problems
This is our code. Since I missed the first lesson my partner, Alex, had to explain ‘scratch’ to me.
In the beginning of the class, Ms. Mok, explained to us what we had to do, which was to create a timer for our balancing board. Alex and I finished that with ease, using the simple code as mentioned above. The harder part was actually connecting the wires to the make-makey and eventually to the actual balancing board. This was a bit tough, because I missed the first lesson and we were a bit unclear on how to connect it. Eventually, however, we figured it out.
Since we finished early and we wanted to push ourselves, so we started working on a piano, using scratch.
In this part, we start by using a function called endgame(), which prints an ascii art of game over, and quits the game. In the bottom, you can see that we use an input variable to receive their name and we then print some text.
Moving on to the next few lines of code (pictured below), we have some information on the storyline of the game. In order for the game to recognize the user’s input based on the choices presented, we used the if, elif, and else operators combined with input variables. We also have some variables, such as vhunger, that increase as the time goes by. You can also see the function endgame(), which was mentioned earlier.
Here are the next few pictures of the code, which use similar operators to those mentioned previously. We also have added comments using #, which you can follow along.
This picture shows clearly how we enabled the user to make their own choices. We set a few options out in front of them, setting the environment for them to make their choices. Then, we give them two options, each with a number in the front. The user would then insert the number and using that, we would proceed with the rest of the code.
For our code, we did not run into too many speedbumps. One problem we encountered was that a few students were a bit too creative and rather than choosing 1 or 2, they choose 3. This automatically advanced our code. In order to fix that, we used an ‘else’ function and made them quit the game.
This was a website that helped me with my while loops. Ms. Mok recommended it to me. One thing that was really helpful about it was that it had a pseudo code to explain what a while loop actually does.
http://stackoverflow.com/
This is a website that we have used many times in class. This website helped me get some ideas for what to do my code on and how to start it of.
Youtube helped me the most. It was much easier seeing someone else do it as it gave me a thorough understanding of how t code properly.
Person References:
I asked Ms. Mok for help. She helped me with my while loops and getting the base syntax about the while loops.
JP helped me test my code
My code was quite interesting. I did a quiz on some fun trivia facts that the user could figure out. As described in the video, I used while loops, if and elif statements. I also added a score count which can be printed at the end of the game and after every question. The while loops were quite simple. As you will see in the code’s annotations, I had a variable for each question. It was always vA<Number of Question>. This was set to the user’s input.
My while loops were when the input variable was not equal to the answer: it would print the hint if the input variable was equal to the hint, otherwise, it would be a wrong answer. I also had an else, thus if the input variable was equal to the answer, it would print out correct.
I also used a variable called vscore to count the score. At the beginning, I set it to zero. Every time they got an answer correct, I added one to the score and printed it out, allowing the user to monitor their progress.
My code with annotations:
#Here I just set the value of the score to 0
vscore = 0
vname = input("""Hello!
Welcome to the MC quiz.
Today you will be quizzed on some general trivia.
Q0) What is your name? \n \n""")
#A short description of the code
print("Alright", vname, "Let's start")
print("""This quiz has 3 types of questions. The first type is multiple choice.
For these questions, you will be provied with 3 options - A, B and C.
To input you answer, simply type A, B or C in UPPER CASE.
The next type will be free answer
For this, you will have to input the answer as a word. Please keep your CAPSLOCK on and don't input any punctuation!
The final type is true or false.
For this you wil have to type either true or false in UPPERCASE.
Remember some questions will offer a hint which doesn't cost you any points to use!
Good Luck!""")
#The First question
print ("""
Q1) Other than East Timor, what is the only other Roman Catholic Country in Asia?
Remember you can ask for a hint by typing "HINT".
""")
#This recognizes the input of the user and sets it to the variable "vA1"
vA1 = input()
#A while loop where the variable is not equal to the answer
while (vA1) != "PHILLIPPINES":
#An optional hint that the user can ask for without any consequences
if vA1 == ("HINT"):
print ("""
This country is in South East Asia. It is made up of over 7,000 Islands.
It was conquered by the Spanish and named after King Phillip II.
It belonged to the United States for a brief amount of time but gained its independence on the July 4, 1946
Now you can take another guess:""")
#This allows the user to take another guess
vA1 = input()
elif vA1 != "PHILLIPPINES":
print ("Sorry wrong answer")
print("Your score is", vscore, "/15")
break
#The else means that when the answer is right, it gives the points.
else:
print ("That's right!")
#It adds 1 to the score here.
vscore = vscore + 1
print("Your score is", vscore, "/15")
print ("""
Q2) There are only 5 capital cities in the world that have a one syllable name. For example: Bern - capital of swizerland.
The other three are Seoul in Korea, Prague the capital of Czech Republic and Minsk the capital Belarus. What is the other one?
Remember you can ask for a hint by typing "HINT".
""")
vA2 = input ()
while (vA2) != ("ROME"):
if vA2 == ("HINT"):
print ("""
Think of the 8th month in the calender and who it resembles!
Now you can take another guess:""")
vA1 = input()
if vA2 != "ROME":
print ("That's wrong!")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
#This is just a true or false question
print ("""
Q3) Jupiter has a liquid core, true or false?
""")
vA3 = input()
#If the input is "true", the right answer it adds the score.
if vA3 == "TRUE":
print("That's right")
vscore = vscore + 1
print("Your score is", vscore, "/15")
#Otherwise it's false and therefore wrong
elif vA3 == "FALSE":
print("Sorry, wrong answer")
print("Your score is", vscore, "/15")
#This is what some would call an 'easter egg'. It is a reference to an inside joke between a few of my classmates and I.
elif vA3 == "LIQUID":
print("Please no")
print("Your score is", vscore, "/15")
#This is if they input anything else.
else:
print ("Sorry wrong answer!")
print("Your score is", vscore, "/15")
print ("""
Q4) Which is the longest english word to be typed on a standard typewriter or a keyboard using only the top row (excluding proper nouns).
Remember you can ask for a hint by typing "HINT".
""")
vA4 = input()
while (vA4) != "TYPEWRITER":
if vA4 == ("HINT"):
print ("""
This tool was invented in 1829 by William Austin Burt and it saved a LOT of ink
Now you can take another guess:""")
vA4 = input()
elif vA4 != "TYPEWRITER":
print ("Sorry wrong answer!")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
#Here's a multiple choice
print("""
Q5) The skeleton of which animal displayed at the Natural History Musuem in the UK is going on a tour next year?
A) A Dinosaur
B) A blue whale
C) A mammoth
Remember you can ask for a hint by typing "HINT"
""")
vA5 = input()
#Instead of actual responses, this just has A,B or C as the options.
while vA5 != "A":
if vA5 == "HINT":
print ("The name of this animal was 'Dippy'")
vA5 = input()
else:
print("Sorry that's wrong")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q6) Which is the only country in the world in which you can see a tiger and a lion in the wild?
A) India
B) Africa
C) Tanzania
""")
vA6 = input()
while vA6 != "A":
print("Sorry, thats wrong!")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("""
Q7) Which animal has a tongue which is 1.5 times the length of its body?
A) Chameleon
B) Snake
C) Frog""")
vA7 = input()
while vA7 != "A":
print ("Sorry that's wrong")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print ("""
Q8) Pigs were chosen as the enemies for these popular characters as swine flu was in news at the time of development of the main plot.
Identify this immensely popular game that was created by Jaakko Iisalo, a senior designer.
Remember you can ask for a hint by typing "HINT"
""")
vA8 = input()
while (vA8) != "ANGRY BIRDS":
if vA8 == ("HINT"):
print ("""
This game had birds fighting the pigs""")
vA8 = input()
elif vA8 != "ANGRY BIRDS":
print ("Sorry wrong answer!")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q9) Which is the only Pixar movie not to be completely animated as it has a small live action piece?
A) Wall-E
B) Up
C) Finding Nemo
""")
vA9 = input()
while vA9 != "A":
print ("Sorry that's wrong ")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q10) In Hinduism, this word literally means "descent" and refers to a deliberate descent of a deity from heaven to earth.
The term was first borrowed by online games and attained global fame in 2009 because of a hollywood blockbuster.
What word?
Remember you can ask for a hint by typing "HINT"!""")
vA10 = input()
while (vA10) != "AVATAR":
if vA10 == ("HINT"):
print ("""
This movie was directed by James Cameron""")
vA10 = input()
elif vA10 != "AVATAR":
print ("Sorry wrong answer!")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q11) In an email software, bcc is used to mark email to somebody anonymously. What does bcc stand for?
A) Blind Carbon Copy
B) before copying correctly
C) Beyond common copy
""")
vA11 = input()
while vA11 != "A":
print ("Sorry! That's the wrong answer")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q12) What is the world’s best selling book?
A) The Holy Bible
B) Harry Potter
C) Quotations from the Works of Mao Tse-tung"
""")
vA12 = input()
while vA12 != "A":
print ("Sorry! That's the wrong answer")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("""
Q13) Which tree is the nation tree of England, Germany, France and the USA?
A) Oak
B) Maple
C) Apple
Remember you can ask for a hint by typing "HINT"
""")
vA13 = input()
while vA13 != "A":
if vA13 == "HINT":
print ("Think of the '**** Tree Shilling' and where its from")
vA13=input()
else:
print("Sorry that's wrong")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q14) Which is taller Eiffel tower of Statue of Liberty
A) Eifeel Tower
B) Statue of Liberty
""")
vA14 = input()
while vA14 != "A":
print("Sorry that's wrong")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("Your score is", vscore, "/15")
print("""
Q15) Why do airplanes dim the cabin lights during take-off or landing.
A) For people to get used to the light outside the window in case of an emergency
B) To save power for takeoff and landing
C) To wake people up
""")
vA14 = input()
while vA14 != "A":
print("Sorry that's wrong")
print("Your score is", vscore, "/15")
break
else:
print ("That's right!")
vscore = vscore + 1
print("""DO YOU WANT YOUR SCORE?
A) YES
B) NO
""")
vA16 = input()
if vA16 == "A":
#This is where I print the score.
print("Your score is", vscore, "/15")
else:
print("Thanks for playing!")
quit()
Today I had a very productive class. With Ms. Mok’s help, I figured out the while loops and I finished the base code. Now, I can copy paste the syntax and change the questions and answers.
Next lesson I want to be finished with my basic code so that I can start shortening my code.
vname = input("""Hello!
Welcome to the MC quiz.
Today you will be quizzed on some general trivia.
Q0) What is your name? \n \n""")
print("Alright", vname, "Let's start")
print("""This quiz has 3 types of questions. The first type is multiple choice.
For these questions, you will be provied with 3 options - A, B and C.
To input you answer, simply type A, B or C in UPPER CASE.
The next type will be free answer
For this, you will have to input the answer as a word. Please use lower case and don't input any punctuation!
The final type is true or false.
For this you wil have to type either true or false in lower case
Good Luck!""")
print ("""
Q1) Other than East Timor, what is the only other Roman Catholic Country in Asia?
Remember you can ask for a hint by typing "hint".
""")
vA1 = input()
while (vA1) != "Phillippines":
if vA1 == ("hint"):
print ("""
This country is in South East Asia. It is made up of over 7,000 Islands.
It was conquered by the Spanish and named after King Phillip II.
It belonged to the United States for a brief amount of time but gained its independence on the July 4, 1946
Now you can take another guess:""")
vA1 = input()
elif vA1 != "phillippines":
print ("Sorry wrong answer")
break
else:
print ("That's right!")
break
print ("""
Q2) Name one of the only five capital cities in the world that have a one syllable name? For example: Bern - capital of swizerland
Remember you can ask for a hint by typing "hint".
""")
vA2 = input()
while (vA2) != "rome" or "seoul" or "prague" or "minsk":
if vA2 == ("hint"):
print ("""
Think of the 8th month in the calender and who it resembles!
Now you can take another guess:""")
vA1 = input()
elif vA2 == "rome":
print ("That's right!")
break
elif vA2 == "seoul":
print ("That's right")
break
elif vA2 == "prague":
print ("That's right")
break
elif vA2 == "minsk":
print ("That's right")
break
else:
print ("That's wrong!")
break
print ("""
Q3) Jupiter has a liquid core, true or false?
""")
vA3 = input()
if vA3 == "true":
print("That's right")
elif vA3 == "false":
print("Sorry, wrong answer")
elif vA3 == "liquid":
print("Please no")
else:
print ("Sorry wrong answer!")
print ("""
Q4) Which is the longest english word to be typed on a standard typewriter or a keyboard using only the top row (excluding proper nouns).
Remember you can ask for a hint by typing "hint".
""")
vA4 = input()
while (vA4) != "typewriter":
if vA4 == ("hint"):
print ("""
This tool was invented in 1829 by William Austin Burt and it saved a LOT of ink
Now you can take another guess:""")
vA4 = input()
elif vA4 != "typewriter":
print ("Sorry wrong answer")
break
else:
print ("That's right!")
break
Today I got the introduction done. I also finished writing my questions which can be found here:
My plan is to use a while loop, however I will have to brush up on that ask I am currently getting an infinite number of responses.
I want to be done with the base code for the quiz by next class.
vname = input("""Hello!
Welcome to the MC quiz.
Today you will be quizzed on some general trivia.
Q0) What is your name? \n \n""")
print("Alright", vname, "Let's start")
print("""This quiz has 3 types of questions. The first type is multiple choice.
For these questions, you will be provied with 3 options - A, B and C.
To input you answer, simply type A, B or C in UPPER CASE.
The next type will be free answer
For this, you will have to input the answer as a word. Please use lower case and don't input any punctuation!
The final type is true or false.
For this you wil have to type either true or false in lower case
Good Luck!""")
vprice = float (10)
vcash = float(input("Please input the money \n \n"))
vchange = float(vcash - vprice)
if vchange == 0:
print("Thank you for the purchase")
elif vchange < 0:
print("insufficient funds")
while vchange > 0:
if vchange >= 10:
print("Despensing $10")
vchange = vchange - 10
elif vchange >= 5:
print ("Despensing $5")
vchange = vchange - 5
elif vchange >= 2:
print("Despensing $2")
vchange = vchange -2
elif vchange >= 1:
print("Despensing $1")
vchange = vchange - 1
elif vchange >= 0.5:
print ("Despenisng $0.5")
vchange = vchange - 0.5
elif vchange <= 1:
print ("Despenisng $0.1")
vchange = vchange - 0.1
This lesson we used our skills such as if, elif and while. We were coding how to code a vending machine. The easy part was to calculate the change. This was simple subtraction. The hard part was to give the change in coins. I used a big while loop in order to keep a continuous loop and the subtracted the value of each coin.
In this lesson, we learnt how to use 'functions'. Functions are 'codes within codes', in other words, you can tell the function to carry out a specific task, or function
and it will record that task under the given name of the function. You first need to define the function and give it a name, as seen in the first line where I
define the function i2p_intro():. Next you need to tell the function what to do, I for example, told the function to print "HKIS n\ I2P n\ same".
When you want to use the funtion, you simply call it by using the 'print'. Make sure to put empty brackets after the name!
def i2p_intro():
print("""
HKIS
I2P
same
""")
print(i2p_intro())
def f_sum(int1,int2):
return int1 + int2
vTotal = f_sum(6,9)
print("The total is",vTotal)
def f_print (int1,int2):
if int1 > int2:
print(int1,"is the largest")
if int1<int2:
print(int2,"is the largest")
print (f_print(10,15))