Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Python notes for year 11 Computer Science

The document provides an overview of Python programming, highlighting its simplicity and versatility. It covers essential topics such as comments, conditional statements, loops, and rare operators, along with examples for clarity. Additionally, it encourages students to explore arrays, data types, and problem-solving exercises to enhance their programming skills.

Uploaded by

bzn5wwwz7x
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python notes for year 11 Computer Science

The document provides an overview of Python programming, highlighting its simplicity and versatility. It covers essential topics such as comments, conditional statements, loops, and rare operators, along with examples for clarity. Additionally, it encourages students to explore arrays, data types, and problem-solving exercises to enhance their programming skills.

Uploaded by

bzn5wwwz7x
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

In order to excel in Problem solving and program, you are required to study the

following:

Python Programming

Python is a high-level, interpreted programming language that was created by Guido


van Rossum and first released in 1991. It is known for its simplicity, readability, and
versatility, making it a popular choice for both beginners and experienced
developers.

For example:

Program to calculate the product of 12 and 13.

Using Python Using Visual Basic


#Program to calculate the product of 12 „Program to calculate the product of 12
and 13 and 13

MyProduct=12*13 #multiplying the „multiplying the numbers


numbers Dim myProduct as decimal = 12*13

Print(MyProduct) #displaying the result „displaying the result


Console.writeline(myProduct)

Note: single line comments start with # Note: Comments start with „, an
apostrophe or REM.
For the purpose of IGCSE, we adopt single
line comments. However, there are other
comment styles too.

It is necessary to add comments to explain most of your program lines.

There are multiple uses of writing comments in Python. Some significant uses
include:

 Increasing readability
 Explaining the code to others
 Understanding the code easily after a long-term
 Including resources
 Re-using the existing code
Students are advised to read up the following and their use:

Rare operators in python:

Expression Symbol
Not equal to != eg. If x!=3:
assignment = eg. myNumber=20
equality == eg, if x== “3”:

Others include

Conditional Statements and Loops

1. if statement

a = 33
b = 200
if b > a:
print("b is greater than a")

2. if …else statement

a = 33
b = 200
if b > a:
print("b is greater than a")

else:

print(“a is greater”)
3. if…then…elif statement

a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")

Loops in python:

1. while loop

Eg. 1

i=1
while i < 6:
print(i)
i += 1

e.g. 2 Result:

i=1 Boma Wellington


while i<5; Boma Wellington
print(“Bomma Wellington”) Boma Wellington
i+=1 #increment is done here Boma Wellington
>>>

2. for loop

NamesofStudents = ["Lorenza", "Ralu", "Tare"] Result:


for x in NamesofStudents:
print(x) Lorenza
Ralu
Tare
>>>

More topics to read up:

Arrays
Data types and use
Using loops with conditional statements
Problem solving exercises

You might also like