More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
post
page
◑ Python IDE Dashboard

The YOLO Challenge

yoloThe YOLO challenge consists of creating an acronym generator: a program that prompts the user to enter an expression or a sentence (e.g. “You only live once!”) and in return gives the acronym matching the user input (e.g. “YOLO”)

Learning Objectives


In this challenge you will further improve your string manipulation techniques and your use of lists in Python. You will investigate how to split a string into a list and how to iterate through each item of a list.

Tips

  • First you may investigate the split() method that can be used on any string:
    myStr = "Millie,Luke,Will,Esther"
    myList = myStr.split(",")
    #This would return a list as follows: ["Millie","Luke","Will","Esther"]
  • You may also look at the upper() and lower() method that can be used to convert a string to UPPERCASE or lowercase.
    For instance:
    myStr.upper() would convert the myStr string to uppercase.
  • To access specific characters of a string using their position you can use the following notation:myStr[0] (This would return the first character of a string called myStr).
  • Finally to iterate through all the values in a list, you may need to use a for loop:
    myList = ["Millie","Luke","Will","Esther"]
    for pupil in myList:
       print(pupil)

Your Turn


Use all of the above tips to complete the YOLO challenge:

Challenge #2


You may want to fine tune your code so that words like “the” or “a” are being ignored.

Tagged with: ,

Fizz-Buzz Game

FizzBuzzFizz buzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word “fizz”, and any number divisible by five with the word “buzz”.

Fizz-Buzz Challenge


For this challenge you need to write a computer program that will display all the numbers between 1 and 100.

  • For each number divisible by three the computer will display the word “fizz”,
  • For each number divisible by five the computer will display the word “buzz”,
  • For each number divisible by three and by five the computer will display the word “fizz-buzz”,

This is what the output will look like:

    1
    2
    Fizz
    4
    Buzz
    Fizz
    7
    …

We have started the game for you… Complete this code (see below) to finish this challenge.

Tip


To find out if a number can be divided by an other number, you will need to check the remainder of the division by using the % sign in Python. For instance:

    7 % 3 = 1 because 7 is not divisible by 3.
    6 % 3 = 0 because 6 is divisible by 3.

So to check if number1 can be divided by number2, you can check if:
number1 % number2 == 0.

Challenge #2


Tweak this code to use the input command in Python. The program should ask the user to input numbers in order or type the word Fizz or Buzz when required. The program should check that the user has typed the right number or the right word and stop if not. It should then give the final score (How far the player completed the game).

Challenge #3


Improve this code further to give the players three lives. The player can make up to 3 mistakes. Each time they make a mistake they lose 10 points but carry on playing till they lose their three lives.
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: ,

Secret Santa

Learning Objectives


This set of challenges focuses on the use of lists in Python. You will learn how to:

  • Initialise a list
  • Add and remove values to a list
  • Find out the length (number of items) of a list
  • Access specific items based on their position in the list
  • Shuffle the content of a list

Before completing this challenge you may want to read more about how Python lists work.

Challenge #1: Random Name Picker


This first challenge is done for you and gives you example of how list can be used to create a random name picker.
The challenge consists of randomly picking up 3 names from a list of pupils’ names and to make sure the same pupil cannot be picked up twice.

SecreatSanta

Challenge #2: Secret Santa


The second challenge consists of organising a Secret Santa list from a list of pupils. The program should output a list where all pupils is given the name of another pupil for who they need to get a present. For instance the output of the program may look like this:

    Laura will get a present for Tobby.
    Ryan will get a present for Laura.
    Tobby will get a present for Ryan.

With this challenge you will need to make sure that every pupil does receive a present and that a pupil does not end up having to give themselves a present.

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Rock-Paper-Scissors

RockScissorsPaper

Did You Know?

Rock-paper-scissors is a hand game usually played by two people, where players simultaneously form one of three shapes with an outstretched hand. The “rock” beats scissors, the “scissors” beat paper and the “paper” beats rock; if both players throw the same shape, the game is tied.

Learning Objectives

By completing this challenge you will improve your programming skills using:

  • Selection: Using if, elif and else statements.
  • Iteration: Using either a for loop or a while loop.

The Game

Check the code below, it enables a player to play against the computer:

Challenge #1

Tweak the code below to allow the players to play 5 games. Keep a score and at the end of the 5 games display the final score and display who between the player and the computer is the overall winner.

Challenge #2

Adapt your code further to play using the best-of-5 playoff: a competition between two players (user and computer) head-to-head which must win three games to win the series. Three is chosen as it would constitute a majority of games played; if one team has won three games before all five games have been played, the games that remain are omitted.

Challenge #3

Adapt your code further to play using the best-of-5 playoff (as above) but where a lead of a minimum of two clear points is required to win the game. For instance you cannot win with a score of 3-2 but you can win with a score of 4-2. (Best of 5 with a 2-clear-point lead).
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Let it snow…

Check this work from year 8 working on the snowflake challenge. Click on each snowflake to see the source code.

Snowflake_1

By Chloe

Snowflake_2

By Phil

Snowflake_3

By Poojan

Snowflake_11

By Lucy

Snowflake_4

By Ben

Snowflake_5

By Thomas

Snowflake_6

By Charlie

Snowflake_7

By Emily

Snowflake_8

By Jude

Snowflake_9

By Katie

Snowflake_10

By Harry

Snowflake_12

By Jude

Snowflake_13

By Jake

snowflake14

By Caroline

Tagged with: , ,

My Logo in Python

Using all the skills we covered in the previous few challenges, we are going to adapt a script to create our own logo using Python Turtle.

First let’s look at the following code:

Challenge


Your challenge consists of tweaking this code to create your own logo. You may want to use your initials, your full name. Alternatively you could create a logo for your form.

Choose your own colours using a colour palette.

101 Computing Logo

Snowflake Challenge

snowflake

Learning Objectives


In this challenge we will use our Python Turtle skills to draw a snowflake.

We will use iteration (For Loop) to recreate each branch of the snowflake.

Step 1: The first branch


First, let’s recap on the main Python Turtle commands:

  • myPen.color(“red”)
  • myPen.forward(100)
  • myPen.right(90)
  • myPen.left(45)
  • myPen.penup()
  • myPen.pendown()
  • myPen.goto(0,0)
  • myPen.circle(50)

snowflake_branchUsing these commands you will need to draw the following pattern:

Step 2: Using a For Loop to complete the snowflake


You are now going to use a for loop to repeat all of this code 6 times and complete your snowflake. Make sure that between each iteration you turn your turtle by 60 degrees.

Remember to use our Python Cheat Sheet to find out how the For loop works.

Video Tutorial


Challenge 2: Let it Snow


Tweak your code to create more complex snowflakes:
snowflakes
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Tagged with: , ,

Leap Year?

calendar

Challenge #1: Leap Year?

Write a program that lets the end-user enter a year using 4 digits (“yyyy” format).

The program should inform the user whether the year entered is a leap year or not.

Challenge #2: Valid and Invalid Dates

Write a program that lets the end-user enter a date using the “dd/mm/yyyy” format.

The program should inform the user whether the date entered is a valid date or not using the following criteria:

“mm” Month Acceptable Date Range (“dd”)
01 January 1 to 31
02 February 1 to 29 on a leap year

1 to 28 otherwise

03 March 1 to 31
04 April 1 to 30
05 May 1 to 31
06 June 1 to 30
07 July 1 to 31
08 August 1 to 31
09 September 1 to 30
10 October 1 to 31
11 November 1 to 30
12 December 1 to 31

My Name is Bond, James Bond

Challenge #1: Hello World!


Write a program that displays the message “Hello World!”

Change your program so that it asks for the end-user to type their firstname. (e.g. “John”)

The program should then display “Hello John!”

Challenge #2: My Name is Bond, James Bond!


Write a program that asks the end-user to enter their firstname and their lastame.

When the user enters their firstname (e.g.”James”) and their lastname (e.g. “Bond”) the program should then display the following output:

“Hello my name is Bond, James Bond”

What’s My Username?

Learning objectives


In this challenge we will use string manipulation techniques to manipulate text data.
In Python a String is a piece of text. It can contain letters, numbers and punctuation signs.

Hello my name is Bond, James Bond

Look at the following code which highlights some key string manipulation techniques:

Using the code above can you tell how to use Python to:

  • Prompt the user to enter their firstname?
  • Concatenate two strings together to create a longer string?
  • Retrieve the first character of a string?
  • Convert a string to uppercase?
  • Calculate the length (number of characters) of a string?
  • Convert a number into a string?

login

Challenge:


Write a program that asks the end-user to enter the following information:

  • Firstname
  • Lastname
  • Year Group

The program should then generate the end-user’s username using the following rules:

  • 2-digit year group + first letter of firstname + lastname
  • The username should be all lowercase
  • If the year group is in 1 digit only (e.g.: 7) then add a “0” in front to make it two digits e.g. “07”

Test your program with the following data:

Firstname Lastname Year Group Expected Output Actual Output
John Lennon 7 07jlennon
Paul McCartney 11 11pmccartney
George Harrison 8 08gharrison
Ringo Starr 9 09rstarr
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area
Privacy Overview

This website will store some information about your preferences on your own computer inside a tiny file called a cookie. A cookie is a small piece of data that a website asks your browser to store on your computer or mobile device. The cookie allows the website to remember your actions or preferences over time.

You can delete all cookies that are already on your computer, and you can set most browsers to prevent them from being placed. However, if you do this, you may have to manually adjust some preferences every time you visit a site, and some services and functionalities may not work.

Most browsers support cookies, but you can set your browser to decline them and can delete them whenever you like. You can find instructions here for how you can do that on various browsers.

This website uses cookies to:

  1. Identify you as a returning user and to count your visits in traffic statistics analysis
  2. Remember your custom display preferences (such as light/dark theme option)
  3. Provide other usability features, including tracking whether you have already given your consent to cookies

Enabling cookies is not strictly necessary for the website to work but it will provide you with a better browsing experience.

The cookie-related information is not used to identify you personally and is not used for any purpose other than those described here.

There may also be other types of cookies created after you have visited this website. This site uses Google Analytics, a popular web analytics service that uses cookies to help to analyse how users use the site. The information generated by the cookie about your use of this website (including your IP address) will be transmitted to and stored by Google on servers in the United States. Google will use this information for the purpose of evaluating your use of other website, compiling reports on website activity, and providing other services relating to website activity and internet usage. Google may also transfer this information to third parties where required to do so by law, or where such third parties process the information on Google’s behalf. Google undertakes not to associate your IP address with any other data held by Google.