What Is Programming
Practical Sheet 1GCSE Python RecapWhat Is ProgrammingExercise 1.1: Recipes for Solving ProblemsThe talk included a recipe for finding the largest number in a list. Create a similar recipe for the two largest numbers in a list.Exercise 1.2: Writing ProgramsTranslate the recipe for finding the largest item in a list into a Python program and test it.Exercise 1.3: Computational ThinkingDiscuss with a neighbour how the ‘Largest Item’ problem illustrates Computational Thinking. Programming ConceptsExercise 2.1: Simple Python Program 1An attraction charges an entrance fee: adults are ?10; children under 18 are half price and the under 5s are free. Write a program to prompt for details of the party before printing a summary of tickets, such as:Alan, ?10Brenda, ?10Charlie, child, ?5Daisy, under 5, freeTotal = ?25Exercise 2.2: Simple Python Program 2Write a program that tells jokes. Each joke should have two parts: the question and the punch line. It should be easy to add more jokes. See website such as for ideas.Exercise 2.3: Suggest a Programming Problem for the Start of Year 12Pupils return from the summer break to start year 12 having obtained an acceptable grade in the GCSE. Unfortunately, they have not done much programming over the break. Suggest a simple programming challenge that meets the following:The problem is interestingIt needs about 10-20 lines of PythonIt only uses Python concepts learnt in GCSEIt can be extended.Exercise 2.4: Python LibraryLook up the standard library online or in the IDLE tool. Online, the documentation URL is . Navigate to the correct version and read the introduction. In Chapter 2, (Built in Functions), lookup and trythe bin() functionthe bool() functionthe range() function In Chapter 4 (Built in Types), lookup:<< operator, e.g. 10 << 2divmod() functionBehaviour of a slice with 3 arguments: [m:n:o]Exercise 2.5: Scope in PythonTry the following program. Can you explain its behaviour?def printX(): print("This is x:", x)y = int(input("Enter a num> "))if y % 2 == 0: x = yprintX()Exercise 2.6: Scope in Python: Global VariablesThe following program uses the ‘global’ keyword and two variables to pass data in and out of the function. Change it to use parameters instead, instead of the global variables.def getYesNo(): global yn yn = "" print(question) while yn != "Y" and yn != "N": yn = input("Enter yes(Y) or no (N): ") yn = yn.upper()question = "Do you like curry?"getYesNo()curry = ynquestion = "Do you like lager?"getYesNo()if yn == "Y" and curry == "Y": print("You are a lager lover, who eats curry")else: print("You loath lager or don't eat curry") Discuss with another course member:Should you teach the global keyword?Should you encourage the use of global variables?Exercise 2.7: ErrorsThe following program is a version of the one from exercise 2.6 containing lots of errors. 1 def getYesNo() 2 global yn 3 print(question) 4 while yn != "Y" and != "N" 5 yn = input("Enter yes(Y) or no (N): ") 6 yn = yn.upper() 7 8 question = "Do you like curry? 9 getYesNo()10 curry = yn1112 question = "Do you like lager?"13 getyesno()14 if yn == "Y" or curry == "Y":15 print("You are a lager lover, who eats curry")16 else:17 print("You loath lager or don't eat curry")Carefully copy the program and complete the following table of errors:Line NumDescriptionType of Error1Missing colon at end of def Syntax errorLearning ProgrammingExercise 3.1: Understanding If Statements and Boolean ExpressionsLearning If statements in Python includes the different forms of If (single case, two cases using else, multiple cases using elif) as well as the possible forms of boolean expressions. Here are some examples:if x > 3: y = y + xif width == 0: print("Error: width zero")else: height = area / width if mark >= 70: grade = "A"elif mark >= 60: grade = "B"else: grade = "C"if mark > 70: grade = "A"if mark < 70 and mark >= 60: grade = "B"mark = "C"Outline how to introduce ‘If Statements’ to develop a pupil’s understanding in stages. Points to consider include:What must be understood before ‘If statements’?Should all aspects of ‘If ’ be introduced together?If not, how many stages should be distinguished?What other language concepts interact with ‘If statements’?Exercise 3.2: Testing Understanding of If StatementsHere is a simple test of a pupil’s understanding of if statements: Do the following two programs behave the same? If not, suggest values of x and y to show the difference:if x % 3 == 0 and y % 3 == 0: print("X, Y are divisible by 3")elif x % 3 == 0: print("X is divisible by 3")elif y % 3 == 0: print("Y is divisible by 3")else: print("Neither divisible by 3")if x % 3 == 0: if y % 3 == 0: print("X, Y are divisible by 3") else: print("X is divisible by 3")else: if y % 3 == 0: print("Neither divisible by 3") else: print("Y is divisible by 3")Complete the test.Create another test – simpler or more complex – for if statements and decide how the two tests fit into your scheme from Exercise 3.1.Create a test of understanding while loops.Exercise 3.3: Problem Solving and Software DevelopmentOutline a plan for writing a game of hangman in Python. Points to consider include:How to specify exactly what the program should do.How to solve the problem in stagesWhat you will write (if anything) before the program.How and when you will test the program. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- using quia www
- asdan provide flexible and engaging programmes and
- gcse scheme of work pearson qualifications
- choices cru
- what is programming
- sabanci university research database
- spelling bingo home campbell county schools
- choiceweek1 cru
- here are some tools that we find particularly useful
- learning home offline activities
Related searches
- it is what is meaning
- and nothing is but what is not
- what is and is not
- what is programming language pdf
- what is computer programming pdf
- what is good and what is evil
- variance is 9 what is standard deviation
- what is something that is 32 feet
- octogenarian is 80 what is 90
- what is viral pneumonia is it contagious
- k is thousand what is a million
- what is what is your opportunity cost