Skip to content
Learnearn.uk » Python Unit Home » Basic Input & Output

Basic Input & Output

Printing  to the screen


There are many ways of outputting data in Python, such as outputting data to a GUI, or moving sprites on a game screen, but the easiest way to output data in Python is to use the print() function.  The job of the print function is just to print text out to the screen, simples!

Printing multiple parts together


Sometimes you don’t just want to print one thing on a line, you might want to print multiple things. For this you can either use a comma or a plus sign.

Comma Vs Plus

Comma ,

  • Always works
  • Adds a space between parts
  • Good for making sentences

Plus +

  • Doesn’t add a space
  • Doesn’t work straight away when combining different data types (e.g numbers and letters)
  • Good for adding the pound sign to numbers, post-codes.

Getting user input


Creating programs that have no user input is pretty boring! There are lot’s of ways to get user input but the simplest way in Python is the input function.

An input statement has 3 parts:

  • First the name of the variable that we want to assign the answer to
  • Second the equals sign, to say we are going to assign a value to the variable
  • Third the input function
Demo

Challenge Instructions

For the rest of this unit you are going to be completing a set number of challenges each week.

For each challenge you must..

  • Go to your challenges folder on Pythonanywhere.com
  • Create a new file called challenge1.py (or whatever challenge number it is)
  • Code and debug your challenge until it works.
  • Copy your finished working code on to the  QuizMaster site.

Challenge 1

ch1

Challenge 2

ch2

Challenge 3

ch3

Challenge 4

ch4

Attribution

Please note these challenges weren’t created by me, they were create by a teacher from Buckhaven High School.

Have you…?checklist2

  • Cut and paste a copy of the code you created for the challenges on to the Quizmaster site (Under Assignments)?
  • Completed the python lesson 1 learning log
  • Written down your homework?
QuizMaster

Downloadable Resources

 

data types workbook

Python Data types workbook

Starter Presentation (sign in to Google to make a copy)