This commit is contained in:
winneratwin 2022-03-02 21:44:03 +00:00
parent d3e90b1de1
commit 988d387625
Signed by: winneratwin
GPG Key ID: CDBC42F8803D689E
17 changed files with 231 additions and 0 deletions

BIN
week 4/C-conds.pdf Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
files: Skill Check 1 - Sequence.doc

View File

@ -0,0 +1,52 @@
import os
from time import sleep
def int_input(text):
while True:
try:
user_input = int(input(text))
return user_input
except Exception:
print("error")
else:
break
def screen_clear():
# for mac and linux(here, os.name is 'posix')
if os.name == 'posix':
_ = os.system('clear')
else:
# for windows platfrom
_ = os.system('cls')
adult_price=10
kid_price=5
screen_clear()
print("Welcome to Superslides inc.")
discount_days = {
"saturday":True,
"sat":True,
"sunday":True,
"sun":True
}
in_service=True
total = 0
while in_service:
adults = int_input("Enter number adult customers: ")
kids = int_input("Enter number children: ")
price = adults*adult_price + kids*kid_price
print("Order price:",price)
total += price
want_to_continue = input("Do you want to process another customer?: ").lower()
screen_clear()
match want_to_continue:
case "yes":
continue
case "y":
continue
case _:
in_service=False

BIN
week 4/L-loops.pdf Normal file

Binary file not shown.

BIN
week 4/Multiply.vsd Normal file

Binary file not shown.

View File

@ -0,0 +1 @@
files: Skill Check 3-Iteration _Loops.doc

View File

@ -0,0 +1,59 @@
import os
from time import sleep
def int_input(text):
while True:
try:
user_input = int(input(text))
return user_input
except Exception:
print("error")
else:
break
def screen_clear():
# for mac and linux(here, os.name is 'posix')
if os.name == 'posix':
_ = os.system('clear')
else:
# for windows platfrom
_ = os.system('cls')
adult_price=10
kid_price=5
screen_clear()
print("Welcome to Superslides inc.")
discount_days = {
"saturday":True,
"sat":True,
"sunday":True,
"sun":True
}
in_service=True
total = 0
while in_service:
adults = int_input("Enter number adult customers: ")
kids = int_input("Enter number children: ")
weekday = input("Day of visit: ")
try:
discount_days[weekday.lower()]
price = adults*adult_price + kids*kid_price
except Exception:
price = (adults+kids)*kid_price
print("Order price:",price)
total += price
want_to_continue = input("Do you want to process another customer?: ").lower()
screen_clear()
match want_to_continue:
case "yes":
continue
case "y":
continue
case _:
in_service=False
print("Total revenue: "+total)

View File

@ -0,0 +1,7 @@
Conditional Statements - Ifs
Loops - While loop / For loop
files:
C-conds.pdf
L-loops.pdf

View File

@ -0,0 +1 @@
files: Skill Check 2-Selectoin _.doc

View File

@ -0,0 +1,57 @@
import os
from time import sleep
def int_input(text):
while True:
try:
user_input = int(input(text))
return user_input
except Exception:
print("error")
else:
break
def screen_clear():
# for mac and linux(here, os.name is 'posix')
if os.name == 'posix':
_ = os.system('clear')
else:
# for windows platfrom
_ = os.system('cls')
adult_price=10
kid_price=5
screen_clear()
print("Welcome to Superslides inc.")
discount_days = {
"saturday":True,
"sat":True,
"sunday":True,
"sun":True
}
in_service=True
total = 0
while in_service:
adults = int_input("Enter number adult customers: ")
kids = int_input("Enter number children: ")
weekday = input("Day of visit: ")
try:
discount_days[weekday.lower()]
price = adults*adult_price + kids*kid_price
except Exception:
price = (adults+kids)*kid_price
print("Order price:",price)
total += price
want_to_continue = input("Do you want to process another customer?: ").lower()
screen_clear()
match want_to_continue:
case "yes":
continue
case "y":
continue
case _:
in_service=False

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -0,0 +1,3 @@
Improving the program
1. Adjustable difficulty. Some people are very good with numbers. They might find being tested on numbers from 1 to 10 rather boring. Some people are very bad with numbers, and might prefer easier questions. Obviously, its not too hard to change the program to use larger or smaller numbers. (Look at the program and make sure you can see how to do that.) It might be more interesting if the program became a little harder every time you get a question right, and a little easier every time you get one wrong. (For this to work well, youd probably need to ask more than 10 questions.)
2. Adjustable length. You might want a quick test, with only four questions. Or a long one, with 100 questions, to see how long you can stay awake. Make the program begin by asking how many questions you want, and then ask that many. To do this, youll need to know about things called “ranges”. Theyre described in Sheet L (Loops).

View File

@ -0,0 +1 @@
files: Multiply.vsd

View File

@ -0,0 +1,49 @@
When you start to think about writing a program, its helpful to begin by thinking exactly what will usually happen when the program runs. Here is an example of a times-table testing program:
Whats 6 times 7?
*49*
*No, Im afraid the answer is 42.*
*Whats 3 times 2?*
*6*
*Thats right well done.*
***And so on, with several more questions. . .***
*Whats 5 times 9?*
*45*
*Thats right well done.*
*I asked you 10 questions. You got 7 of them right.*
*Well done!*
So, here are some things we need to be able to make the computer do:
Choose numbers (at random, preferably)
Display a sum
Calculate the right answer
Get an answer from the person using the program
See whether its right or not
Display a final message saying how youve done
Display a “thats right” or “thats wrong” message
Keep count of how many questions were answered right
Ask a total of (say) 10 questions, and then stop
...........................Thats quite a lot of things to do!