0% found this document useful (0 votes)
4 views15 pages

Python Basics

This document outlines a 10-week programming course in Python, covering topics such as IDLE, data types, operators, control structures, functions, file handling, and databases. It includes key learning points, example codes, and challenges for practical application. The course emphasizes understanding variables, user input, and basic programming concepts.

Uploaded by

Naushin Mirza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

Python Basics

This document outlines a 10-week programming course in Python, covering topics such as IDLE, data types, operators, control structures, functions, file handling, and databases. It includes key learning points, example codes, and challenges for practical application. The course emphasizes understanding variables, user input, and basic programming concepts.

Uploaded by

Naushin Mirza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

PROGRAMMING

IN PYTHON
Ms Mirza - Week 1
10 WEEK COURSE
Introduction to IDLE, basic input & output, data types, operators, casting, variables &
05/10/17
assignment.

12/10/17 Selection, nested selection 'if & elif', string manipulation, commenting code
Key Words
Using modules, Iteration 'For & While loops’
19/10/17
Variables
02/11/17 Strings & slicing, Lists -searching/sorting/list manipulation/operations Assignment
Casting
09/11/17 Multi-dimensional lists, exception handling, common mistakes and debugging Operators
Concatenate
16/11/17 Functions and procedures, functions with parameters Identifier
File handling, reading from files, writing to files
Sequencing
23/11/17 Selection
Code challenges, NEA examples & tasks Iteration
30/11/17
Arrays
Databases & SQLite
07/12/17

Regular expressions & Dictionaries


14/12/17
INTRODUCTION TO IDLE
Key Words

Variables
Assignment
This is the shell, it is the Casting
interactive environment Operators
Choose File... New File... Concatenate
To open a new window Identifier
Sequencing
The script mode is used to write Selection
programs to run later. Iteration
When you save your program, Arrays
make sure to add .py extension to
the filename
WRITING YOUR FIRST
PROGRAM
 Enter the following sequence of instructions:
Key Words

Variables
Assignment
Casting
Operators
Concatenate
Identifier
Sequencing
Selection
Note the hash Iteration
Concatenation
symbol enables Arrays
joining strings
you to insert a
using a comma
comment in the
code.
KEY LEARNING POINTS
 Text is known as a string in programming and must be
enclosed in single or double quotes.
Key Words
 When a program is run (F5) it is called executing the
program. Variables
Assignment
 Strings can be joined together using a comma or plus Casting
symbol. This is known as concatenation. Operators
Concatenate
 A set of instructions that execute one after another is Identifier
known as a sequence. Sequencing
Selection
 Comments can be inserted into the code using a hash Iteration
symbol. These are helpful to make notes within the Arrays
program so that the code can be understood again at a
later date or by another programmer.
KEY WORDS
Key Words
Key Example code Purpose
word Variables
Assignment
print() print(‘x’) To output an x string to the screen
followed by a carriage return Casting
Operators
print(‘x’, end=’’) To disable the carriage return and Concatenate
print on one line Identifier
Sequencing
Selection
Iteration
Arrays
CHALLENGE
 Write a program that will print out the number 5 on a dice
like this: Key Words

Variables
Assignment
Casting
Operators
Concatenate
Identifier
Sequencing
Selection
Iteration
Arrays
UNDERSTAND HOW TO INPUT STRINGS AND NUMBERS INTO VARIABLES

Key Words

Variables
Assignment
Casting
Operators
Concatenate
Identifier
Sequencing
Casting
Selection
changing the
Iteration
type of data you
Arrays
are working
with
KEY LEARNING POINTS
 Data is input by a user into a variable.
 Variables have a data type: string, integer or float as Key Words
examples, indicating how much memory they will use and
Variables
the type of data they will store. Assignment
 Python does not require variables to be declared before they Casting
Operators
can be used. Concatenate
 Changing a data type you are working with is called casting Identifier
Sequencing
Selection
Iteration
Arrays
KEY WORDS
Key Example code Purpose
word
input() x = input("Enter your name:") to store text input at the keyboard
into a variable, x which can be used Key Words
later in the program without inputting
again. Variables
Assignment
Casting
int() x = int(x) Convert variable x to an integer. Most
Operators
useful to convert a string input to a
Concatenate
number because the character “5” is
Identifier
not the same as the number 5 to a
Sequencing
computer.
x = int(input("Enter your Selection
age:")) Combining input and int enables the Iteration
input of a number Arrays

float() x = float(x) convert variable x to a floating point


(decimal) number.

The characters “5.5” are not the same


CHALLENGES – DIFFICULTY LEVEL 1
Simple adder challenge
 Write a program that asks the user for two numbers, adds them Key Words
together and outputs for example: You entered numbers 5 and 12
They add up to 17 Variables
Assignment
Test marks challenge Casting
Operators
 Write a program that will ask the user to enter three test marks
Concatenate
out of 100 and output the average. Identifier
Sequencing
Temperature converter challenge Selection
 Write a program to enter a temperature in degrees Fahrenheit Iteration
and display the equivalent temperature in degrees Centigrade. Arrays
The formula for conversion is Centigrade = (Fahrenheit – 32) *
(5/9)
CHALLENGES – DIFFICULTY LEVEL 2
Height & weight challenge
 Write a program to convert a person’s height in inches into
centimeters and their weight in stones into Key Words
 kilograms. [1 inch = 2.54 cm and 1 stone = 6.364 kg]
Variables
Toy cars challenge Assignment
Casting
 A worker gets paid £9/hour plus £0.60 for every toy car they make
Operators
in a factory. Write a program that allows the worker to enter the Concatenate
number of hours they have worked and the number of trains they Identifier
have made. The program should output their wages for the day. Sequencing
Selection
Fish tank volume challenge Iteration
 Write a program that will ask the user to enter the length, depth Arrays
and height of a fish tank in cm. Calculate
 the volume of water required to fill the tank and display this
volume in litres and UK gallons. To calculate volume in litres,
multiply length by depth by height and divide by 1000.
HANDY TIPS
Tip Code example

Key Words
Comments can
be single line or Variables
multiline Assignment
Casting
Operators
Concatenate
Identifier
You can include Sequencing
line breaks or Selection
tabs in your Iteration
code. Arrays

Using single
and double line
quotes
SOME ESCAPE SEQUENCES
Key Words

Variables
Assignment
Casting
Operators
Concatenate
Identifier
Sequencing
Selection
Iteration
Arrays
Only works if your are
working in the
command line and
not in idle
BASIC INPUT AND OUTPUT
Key Words

Variables
Assignment
Casting
Operators
Concatenate
Identifier
Sequencing
Selection
Iteration
Arrays

You might also like