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
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.
Attribution
Please note these challenges weren’t created by me, they were create by a teacher from Buckhaven High School.
Have you…?
- 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?