Python Challenges Python Challenge 1 Write a program
- Slides: 63
Python Challenges
Python Challenge 1 Write a program that: • asks the user to input their age • outputs 'Your age is: ' followed by their age 1 Difficulty: © Zig. Zag Education, 2014 1 You will need to use: Sequencing Variables
Python Challenge 1 1 point [x 1] The program asks th e user to input their age. 2 points [x 1] The age is outputte d. 3 points [x 1] The output includes the text ‘Your age is: ’ plus the age. © Zig. Zag Education, 2014
Python Challenge 2 Write a program that: • asks the user to input two numbers • calculates the average • outputs the result 2 You will need to use: Tip: To calculate the average of two numbers you need to add them together and divide them by two. 1 Difficulty: © Zig. Zag Education, 2014 Sequencing Variables
Python Challenge 2 1 point [x 1] The program asks th e user to input two numbe rs. 2 points [x 1] The average is calc ulated and outputted; how ever, it may not be correct. 3 points [x 1] The average is calc ulated correctly and output ted. © Zig. Zag Education, 2014
Python Challenge 3 Write a program that: • asks the user to input the width and height of a rectangle • calculates the area • outputs the result 3 You will need to use: Sequencing Variables Tip: Multiply the width by the height to find the area of a rectangle. 1 Difficulty: © Zig. Zag Education, 2014
Python Challenge 3 1 point [x 1] The program asks th e user to input the width an d height of a rectang le. 2 points [x 1] The area is calculat ed and outputted; however , it may not be correct. 3 points [x 1] The area is calculat ed correctly and output ted. © Zig. Zag Education, 2014
Python Challenge 4 Write a program that: • asks the user to input two numbers • divides the first number by the second number • outputs the result 1 Difficulty: © Zig. Zag Education, 2014 4 You will need to use: Sequencing Variables
Python Challenge 4 1 point [x 1] The program asks th e user to input two numbe rs. 2 points [x 1] The program divides the first number by the second number. 3 points [x 1] The result is output te d. © Zig. Zag Education, 2014
Python Challenge 5 Write a program that: • asks the user their name • asks what their favourite subject is (using their name in the question) • responds to their answer by saying that you like that subject as well 1 Difficulty: © Zig. Zag Education, 2014 5 You will need to use: Sequencing Variables
Python Challenge 5 1 point [x 1] The program asks th e user for their name and their favourite food. 2 points [x 1] The program asks th e user for their favourite fo od using their name in the question. 3 points [x 1] The program output sa sentence that includ es their favourite food. © Zig. Zag Education, 2014
Python Challenge 6 Write a program that: • asks the user their name • if it is the same as your name, outputs 'You’re cool', otherwise outputs 'Nice to meet you' 2 Difficulty: © Zig. Zag Education, 2014 6 You will need to use: Selection Variables
Python Challenge 6 1 point [x 2] The program asks th e user to input their name. 2 points [x 2] If the inputted nam e is the same as the programmer’s na me, the program outputs ‘You’re cool’. 3 points [x 2] If the inputted nam e is not the same as the programmer’s na me, the program outputs ‘ Nice to meet you’. © Zig. Zag Education, 2014
Python Challenge 7 Write a program that: • asks the user how long on average they spend watching TV each day • if it is less than 2 hours, outputs ‘That shouldn’t rot your brain too much’; if it is less than 4 hours per day, outputs ‘Aren’t you getting square eyes? ’; otherwise outputs ‘Fresh air beats channel flicking’ 2 Difficulty: © Zig. Zag Education, 2014 7 You will need to use: Selection Variables
Python Challenge 7 1 point [x 2] The program asks th e user how long they spen d on a computer per day. 2 points [x 2] If the response is le ss than 2, it outputs ‘That seems reasonable’. 3 points [x 2] If the response is le ss than 4, it outputs ‘I’m surprised you have time for anything else!’ , otherwise it output s ‘You need to get some fr esh air once in a while’. © Zig. Zag Education, 2014
Python Challenge 8 Write a program that: • converts and outputs marks into grades, using the following data: Greater than or equal to 75 A Greater than or equal to 60 Greater than or equal to 35 Less than 35 B C D 2 Difficulty: © Zig. Zag Education, 2014 You will need to use: Selection Variables
Python Challenge 8 1 point [x 2] The program asks th e user to input the studen t’s mark. 2 points [x 2] The program conver ts most marks to grad es correctly. 3 points [x 2] The program conver ts all marks to grades co rrectly. © Zig. Zag Education, 2014
Python Challenge 9 Write a program that: • asks the user to name one of the Olympic Values (Respect, Excellence and Friendship) • if they correctly name one, output 'That’s correct‘, otherwise output 'Try again' 2 Difficulty: © Zig. Zag Education, 2014 9 You will need to use: Selection Variables
Python Challenge 9 1 point [x 2] The program asks th e user to input the name of one of the Olympic valu es. 2 points [x 2] The program output s ‘That’s correct’ if they enter a valid Olympi c value. 3 points [x 2] The program output s ‘Try again’ if they ente r an invalid Olympic valu e. © Zig. Zag Education, 2014
Python Challenge 10 Write a game that: • allows the user to play rock, paper, scissors against the computer • must display the computer’s choice and show the result of the game Tip: The computer’s answer must be random. 2 Difficulty: © Zig. Zag Education, 2014 10 You will need to use: Selection Variables
Python Challenge 10 1 point [x 2] The program asks th e user to select rock, pape r or scissors. 2 points [x 2] The outcome of the game is correctly calculat ed. 3 points [x 2] The computer’s an swer is random. © Zig. Zag Education, 2014
Python Challenge 11 Write a program that: • asks the user to input a sentence • calculates and outputs how many characters there are in the sentence 3 Difficulty: © Zig. Zag Education, 2014 11 You will need to use: Variables String Manipulation
Python Challenge 11 1 point [x 3] The program asks th e user to input a sentence. 2 points [x 3] The program output s the number of characte rs in the sentence. 3 points [x 3] The program output s an appropriate string along with the number of characters in the se ntence. © Zig. Zag Education, 2014
Python Challenge 12 Write a program that: • asks the user to input a sentence • outputs the sentence in upper case 12 You will need to use: Variables String Manipulation 3 Difficulty: © Zig. Zag Education, 2014
Python Challenge 12 1 point [x 3] The program asks th e user to input a sentence. 2 points [x 3] The program output s the original sentence. 3 points [x 3] The program output s the sentence in upper ca se. © Zig. Zag Education, 2014
Python Challenge 13 Write a program that: • asks the user to input a sentence • asks the user to input: • the word they want to replace it with • outputs the new sentence 3 Difficulty: © Zig. Zag Education, 2014 13 You will need to use: Variables String Manipulation
Python Challenge 13 1 point [x 3] The program asks th e user to input a sentence and the word they want to replace. 2 points [x 3] The program output s the original sentence. 3 points [x 3] The program output s the sentence with the w ord replaced. © Zig. Zag Education, 2014
Python Challenge 14 Write a program that: • asks the user to input a sentence • outputs the number of times the word 'the' occurs in it 3 Difficulty: © Zig. Zag Education, 2014 14 You will need to use: Variables String Manipulation
Python Challenge 14 1 point [x 3] The program asks th e user to input a sentence. 2 points [x 3] The program counts the number of times ‘ the’ occurs in it. 3 points [x 3] The program output s the number of times ‘ the’ occurs in it. © Zig. Zag Education, 2014
Python Challenge 15 Write a program that: • asks the user to input a sentence • outputs the sentence in lower case 15 You will need to use: Variables String Manipulation 3 Difficulty: © Zig. Zag Education, 2014
Python Challenge 15 1 point [x 3] The program asks th e user to input a sentence. 2 points [x 3] The program output s the original sentence. 3 points [x 3] The program output s the sentence in lower ca se. © Zig. Zag Education, 2014
Python Challenge 16 Write a program that: • outputs all numbers between 1 and 10 You will need to use: Variables Repetition Tip: You must use a For Loop for this challenge. 3 Difficulty: © Zig. Zag Education, 2014
Python Challenge 16 1 point [x 3] The program output s some numbers to the scre en. 2 points [x 3] The program output s the numbers 1 to 10. 3 points [x 3] The program uses a For loop to output the numbers 1 to 10. © Zig. Zag Education, 2014
Python Challenge 17 Write a program that: • outputs all odd numbers between 1 and 99 Tip: You must use a For Loop for this challenge. 3 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Repetition
Python Challenge 17 1 point [x 3] The program output s some numbers to the scre en. 2 points [x 3] The program output s some odd numbers. 3 points [x 3] The program output s all the odd numbers fr om 1 to 99. © Zig. Zag Education, 2014
Python Challenge 18 Write a program that: • asks the user to input a number • outputs the times table for that number Tip: You must use a For Loop for this challenge. 3 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Repetition
Python Challenge 18 1 point [x 3] The program asks th e user to input a number. 2 points [x 3] The program output s the time table for the in putted number. 3 points [x 3] The program includ es a For loop to generat e the times table. © Zig. Zag Education, 2014
Python Challenge 19 Write a program that: • asks the user to input a number • outputs the times table for that number • starts again every time it finishes 19 You will need to use: Variables Repetition Tip: You must use a For Loop and a While Loop for this challenge. 3 Difficulty: © Zig. Zag Education, 2014
Python Challenge 19 1 point [x 3] The program asks th e user to input a number. 2 points [x 3] The program output s the times table for the number given. 3 points [x 3] A While loop has be en used to make the pr ogram repeat forever. © Zig. Zag Education, 2014
Python Challenge 20 Write a program that: • asks the user to input a number and repeats until they guess the number 7 • congratulate the user with a ‘Well Done’ message when they guess correctly 3 Difficulty: © Zig. Zag Education, 2014 20 You will need to use: Variables Repetition
Python Challenge 20 1 point [x 3] The program asks th e user to guess the numbe r. 2 points [x 3] If they input the nu mber 7, the program will ou tput ‘Well Done’. 3 points [x 3] The program loops until the user inputs the number 7. © Zig. Zag Education, 2014
Python Challenge 21 Write a program that converts between centimetres, and inches and vice versa, by: • asking the user to input a number • asking the user to choose between converting from centimetres to inches or from inches to centimetres • calculating and outputting the result using functions Tip: 1 inch = 2. 54 cm 1 cm = 0. 393700787 inches 3 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Selection Functions
Python Challenge 21 1 point [x 3] The program asks th e user to choose the type of the conversion they wan t to carry out and to inpu t the number they want to convert. 2 points [x 3] The program correc tly converts between in ches and centimetres. 3 points [x 3] The program uses se parate functions to conver t between inches and centimetres. © Zig. Zag Education, 2014
Python Challenge 22 Write a program that: • asks the user for the distance (in metres) • asks the user for the time in seconds that a journey was completed in • calculates and outputs the average speed using a function Tip: Speed = Distance / Time 3 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Selection Functions
Python Challenge 22 1 point [x 3] The program asks th e user to input the distanc e and time. 2 points [x 3] The program correc tly calculates the averag e speed. 3 points [x 3] The program uses a function to calculat e the average speed. © Zig. Zag Education, 2014
Python Challenge 23 A gardener needs to buy some turf for a project they are working on. The garden is rectangular with a circular flower bed in the middle. Write a program that: • asks the user for the dimensions of the lawn and the radius of the circle (in metres) • uses a function to calculate and output the amount of turf needed Tip: Circle area = Pi x Radius 2 4 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Selection Functions
Python Challenge 23 1 point [x 4] The program asks th e user to input the dimen sions of the lawn and the ra dius of the circle. 2 points [x 4] The program correc tly calculates the amou nt of turf required. 3 points [x 4] The program uses a function to calculat e the amount of turf requi red. © Zig. Zag Education, 2014
Python Challenge 24 Write a function that takes two numbers. The first number indicates the number of spaces that should be displayed and the second indicates the number of Xs that should be displayed. These should both be displayed on the same line. Now write another function that makes multiple calls to your first function and draws a picture with Xs. 4 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Selection Repetition Functions
Python Challenge 24 1 point [x 4] The program display sa number of spaces fo llowed by a number of Xs on the same line. 2 points [x 4] The program uses a function to output a set number of spaces an d Xs on the same line. 3 points [x 4] The program uses an other function to draw a picture using the first func tion. © Zig. Zag Education, 2014
Python Challenge 25 Write a sign-up program for an afterschool club; it should ask the user for the following details and store them in a file: • • First Name Last Name Gender Form 4 Difficulty: © Zig. Zag Education, 2014 You will need to use: Variables Selection File Handling
Python Challenge 25: Solution #!/usr/bin/python 3 print("----CLUB SIGN UP----") #User enters their details first=input("Enter your first name: ") last=input("Enter your last name: ") gender=input("Enter your gender: ") form=input("Enter your form: ") #Opens the file or creates it if it doesn't already exist file = open("signup. txt", "a") #Records the user's details in the file. write("n. First name: "+first+", Last name: "+last+", Gender: "+gender+", Form: "+form) #Closes the file. close() © Zig. Zag Education, 2014 25 1 point [x 4] The program asks th e user to input their First N ame, Last Name, Gender and Form. 2 points [x 4] The data is stored in an external text file. 3 points [x 4] The data is stored w ith appropriate labels in an external text file.
Python Challenge 26 Write a maths quiz with three questions. It must ask the user to input their name at the start. At the end it should display a message informing the user of their score. Write a function that saves the user’s name and quiz result in a text file. 4 Difficulty: © Zig. Zag Education, 2014 26 You will need to use: Variables Selection Functions File Handling
Python Challenge 26 1 point [x 4] The program asks th e user to input their name and then asks three mat hs questions. 2 points [x 4] At the end of the q uestions the program display s the user’s name follow ed by their score. 3 points [x 4] A function has been used to save the user’s name and quiz result to a text file. © Zig. Zag Education, 2014
Python Challenge 27 Extend your maths quiz program from Challenge 20 by including a list of the scores of people that have taken the quiz before. You will need to use: Variables Selection File Handling 5 Difficulty: © Zig. Zag Education, 2014
Python Challenge 27 1 point [x 5] The program open s an external file. 2 points [x 5] The program loads the scores from an exte rnal file. 3 points [x 5] The program display s the scores from an exte rnal file. © Zig. Zag Education, 2014
Python Challenge 27 1 point [x 5] The program open s an external file. 2 points [x 5] The program loads the scores from an exte rnal file. 3 points [x 5] The program display s the scores from an exte rnal file. © Zig. Zag Education, 2014
Python Challenge 28 Write a random name generator that asks for the user to input 5 names, stores them in an array and then outputs one of them at random. You will need to use: Variables Repetition Arrays 5 Difficulty: © Zig. Zag Education, 2014
Python Challenge 28 1 point [x 5] The program asks th e user to input 5 names. 2 points [x 5] The program stores the names in an array. 3 points [x 5] The program output sa random name from the array. © Zig. Zag Education, 2014
Python Challenge 29 Write a program that allows the user to create and store a checklist for a holiday. It should start by asking them the destination of the holiday, how many things they need to pack and how many tasks they need to complete to prepare. The user should then be able to enter each item they need to pack and each task they need to complete. 5 Difficulty: © Zig. Zag Education, 2014 29 You will need to use: Variables Repetition Arrays File Handling
Python Challenge 29 1 point [x 5] The program asks th e user for the destination of their holiday, how many things they need to pack an d how many tasks they ne ed to complete. 2 points [x 5] The program should use a For loop to ask the user to input each item they need to pack and each task they need to complete. 3 points [x 5] The program should store the inputted data in an external file in a clea r and easy-to-read format. © Zig. Zag Education, 2014
Python Challenge 29 1 point [x 5] The program asks th e user for the destination of their holiday, how many things they need to pack an d how many tasks they ne ed to complete. 2 points [x 5] The program should use a For loop to ask the user to input each item they need to pack and each task they need to complete. 3 points [x 5] The program should store the inputted data in an external file in a clea r and easy-to-read format. © Zig. Zag Education, 2014
Python Challenge 30 Improve your maths quiz from Challenge 20 and 27 by storing all the questions and possible answers in a twodimensional array. Write a function that can be reused to ask each of the questions. You will need to use: Global Variables Repetition Functions 2 D Arrays 5 Difficulty: © Zig. Zag Education, 2014
Python Challenge 30 1 point [x 5] An attempt has been made to make a two-dim ensional array. 2 points [x 5] The program uses a twodimensional array to store the questions and an swers for a quiz. 3 points [x 5] A For loop is used to ask the questions stored in the two-dimensional ar ray. At the end of the quiz the user’s score must be saved to an external file. © Zig. Zag Education, 2014
- Welcome to teen challenge uk - teen challenge uk
- Python challenge 19
- Python about
- Deklarasi stack
- Contoh array 2 dimensi python
- Python menu driven program
- Program gerobak fried chicken python
- Python program
- Create python program
- Karakteristik write through didalam write policy
- Write a program to count blanks tabs and newlines
- Allegro write program
- Write a menu driven program
- Write a program
- Sequential program and an event-driven program?
- Perangkat lunak disebut juga
- Menyusun program tahunan dan program semester
- Microsoft excel merupakan program aplikasi yang disebut
- Microsoft excel merupakan perangkat lunak buatan ....
- Program ms word merupakan program …. *
- War at home vs war abroad madison
- Chapter 16 lesson 2 challenges to slavery
- Topic 7 economic performance and challenges
- Netflix big data portal
- Challenges of christianity in the modern world
- 3 filipino adolescent heroes
- Achievement of mkukuta
- Three challenges in doing semantics
- Sdn security challenges
- Software quality challenges
- Linda r greene
- How to show challenges in ppt
- What are some of the opportunities of media and information
- Unexpected challenges 1995
- Stigma associated with failure and repetition is removed
- Challenges of job analysis
- Challenges of investigative reporting in kenya
- Challenges in embedded system design
- Three challenges in doing semantics
- Challenges of international business
- Taha hussein challenges
- Challenges facing global managers
- The federalist era lesson 2 early challenges
- Emerging challenges of industrial relations in india
- Challenges of novel drug delivery system
- Contemporary management issues
- Configuration management challenges
- Bruce oestreich
- Challenges in network forensics
- The land fatma omara
- Challenges of global information systems chapter 9
- Challenges of service innovation and design
- Social integration by emile durkheim
- Challenges of bpr
- What are the leadership challenges for the youth of today
- Chapter 38 challenges to the postwar order
- Chapter 36 patients with special challenges
- Managing diversity and regulatory challenges
- Global sourcing international business
- Rizal challenges retana to duel
- App monetization challenges
- Dual career path example
- Ihrm trends
- Software quality challenge