top of page

Python - #3 - Inputs

1. Asking Questions

Input means to enter data into a program.

​

Use the input command to ask a question.

​

You must save the answer into a suitably named variable using the = symbol.

input1.PNG
inpu2.PNG

Task 1 - Create a new Python program and save the file as 3-Inputs.py

​

Use the picture to help you ask what someone's name is. Run the program and type your name.

When you run the program (F5) you can type your answer on any question line in the Python Shell.

2. Asking more Questions

There is no limit to how many questions you can ask in Python. It is the most important way to interact with the user of your program.

Task 2 - Ask two more questions on topics of your choice.

input3.PNG

3. Using Variables in a Sentence

When we have printed the answers so far, they have not been very informative!

​

You can print variables together with sentences so that they mean more.

​

Use a comma ( , ) between variables and sentences.

Task 3 - Use the pictures to help you add commas and sentences to your program to be more informative.

input4.PNG
input6.PNG

BONUS: After I took the screenshot of my code I added in print lines in the two blanks spaces that print a line of dashes. Try to do the same to make your program easier to read.

4. Using Integers

An integer is a whole number.

​

When you are asking a question that you know will have a number for an answer, you need to add int( before your input.

​

Don't forget to add double close brackets at the end of the question line!

Task 4 - Underneath your previous questions (don't delete anything) ask 2 questions that will have numbers for answers. 

You must use int( - see the image for help.

input8.PNG
input7.PNG

Challenge Programs

Use everything that you have learned on this page to help you create these programs...

​

Challenge Task 1 - Funny Food

  1. Create a new Python program. Save it as '3-FunnyFood.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks two questions, one for their favourite colour and one for their favourite food.

  4. Print a funny sentence using both of their answers.

​

  • BONUS: Try to use only one print line.

​

  • Remember: Break up variables in a print line by using commas.

​

When you run it, it could look something like this:

Challenge Task 2 - Trivia Question

  1. Create a new Python program. Save is as '3-Trivia.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks the user a trivia question of your choice.

  4. Print the correct answer AND their answer.

​

  • BONUS: Use only one print line.

  • BONUS: Try to use only two lines in total.​

    Remember: Break up variables in a print line by using commas.

​

When you run it, it could look something like this:

input9.PNG
input10.PNG

Challenge Task 3 - Getting to School

  1. Create a new Python program. Save it as '3-School.py'

  2. Add a comment at the top with your name and the date.

  3. Create a program that asks two questions, one for how they get to school and one for how long it takes. Don't forget - use int( and then double close brackets for a number!

  4. Print an appropriate response that uses both of their answers.

​

  • BONUS: Use two separate input lines.

  • BONUS: Try to use only one print line.​

    Remember: Break up variables in a print line by using commas.

​

When you run it, it could look something like this:

input11.PNG
bottom of page