Download presentation
Presentation is loading. Please wait.
Published byGervase Pierce Modified over 6 years ago
1
To write a Python program, you first need to open Pyscripter
To write a Python program, you first need to open Pyscripter. Go to the shared area\ICT\Portable Python and double click on Pyscripter-Portable.exe
2
You will see a screen like the one below
You will see a screen like the one below. Remove the code in the main window and then you’re ready to go!
3
Now press the run button:
Your first program: Hello world Type the below code into the main window: print(“Hello World”) Now press the run button: You should see the output: Now try to get it to output ‘Hello (Your Name)’
4
Next we’re ready to use variables:
someText = input(“What is your name?”) print(“Welcome ” + someText) Now see if you can get the computer to also ask what your favourite colour is and what your favourite animal is. Then it should output a sentence like: Your teacher will show you this video to help understand variables (until 1min 30s):
5
Time to do some calculations, try each of these:
print( ) print( ) print(1234*67) print(12000/4)
6
Now try this: someNumber = 345 anotherNumber = 457 Print(someNumber + anotherNumber) Now try dividing, multiplying and subtracting someNumber and anotherNumber
7
We can now try making a calculator by asking for two numbers and storing them in variables:
num1 = input(“Enter the first number”) num2 = input(“Enter the second number”) However, the computer will assume these numbers are text, so now we have to convert them to numbers (integers): num1 = int(num1) num2 = int(num2)
8
Now try to get the computer to print the answer to num1 multiplied by num 2
And try to get the computer to print the answer to num1 added to num 2
9
You can make it a bit more user friendly by putting some additional text in:
print(“The answer to “ , num1 , “ multiplied by “ , num2 , “ is: “ , num1*num2)
10
Now it’s time to make a miles to kilometres converter program Can you make a program that: - Asks how many miles you would like to convert - Stores the answer in a variable - Converts the contents of that variable into a number - Multiplies the number of miles by the number of kilometres in a miles (you can find this information out on the web) - Prints out the answer saying something like “The number of kilometres in 6 miles is 9.65 kilometres”
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.