0% found this document useful (0 votes)
3 views

Revision Q2 5G10

Uploaded by

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

Revision Q2 5G10

Uploaded by

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

Al Manar Language School

American section
IT Department

Q2 G10 Revision Notes


Python Turtle:-
Main command in python turtle:-
To Move forward Go (100)
To go back Go (-100)
To turn right Turn (90)
To turn left Turn (-90)
To change line color Color(“green”)
To change line width Width(10)
To clear the screen Reset()
To make the turtle invisible Invisible()
To make the turtle visible Visible()
To draw with the pen Pen_down()
To draw without pen Pen_up()
To clear the screen Clear()

To draw a square: - (two ways )

Go (100)
Turn(90)
Go(100)
Turn(90)
Go (100)
Turn(90)
Go (100)
Turn(90)
**************************************************************
for i in range ( 4 ):
go(100)
turn(360/4)

Write the code for the following shapes:-

# to draw the triangle


For i in range ( 3):
Go (100)
Turn( 360/3)
#To draw the square :-
For i in range ( 4):
Go (100)
Turn( 360/4)

For i in range ( 5):


Go (100)
Turn( 360/5)

For i in range ( 36):


Go (10)
Turn( 10)
\

Python Basics Revision Notes


1. Introduction to Python
• Python is a high-level, versatile programming language, designed to be easy to
learn and use.
• Known for its readability and conciseness, Python is used for web
development, data analysis, machine learning, and more.

• Example of Python simplicity:

print("Hello, World")

• Key features:
o Open-source: Free to download and use for any purpose.
o Large community: Provides extensive resources, tools, and libraries.

3. Writing Your First Python Program

• Python programs can be written interactively or saved in .py files.


o Example:

>>> print("Hello, World")

Output>>>Hello, World

4. Variables and Data Types


Rules for defining variable
1. A variable can contain alphabets, Digits, and underscores.
2. A variable can only start with an alphabet or underscores (_).
3. A variable name can’t start with a digit.
4. No white space is allowed to be used inside a variable name.
For example: x1, _Shamim, principle
Variables
Creating Variables
Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it
Example

x=5
y = "John"
print(x)
print(y)

• Variables store data for reuse.


• Declaration:

greeting = "Hello, World"

• Case-sensitive (e.g., name ≠ Name).

• Case-Sensitive
• Variable names are case-sensitive.
• Example
• This will create two variables:
• a = 4
A = "Sally"
#A will not overwrite a

• a=4
• A = "Sally"
• print(a) output >>>> 4
• print(A) output >>>> Sally

Data Types
1. Strings: Text enclosed in quotes. Example : name = "Alice"
2. Numbers: Integers: Whole numbers. Example : age = 25
Floats: Decimal numbers. Example : height = 5.9
3. Boolean: Represents True or False.

Python Conditions and If statements


Python supports the usual logical conditions from mathematics:
• Equals: a == b
• Not Equals: a != b
• Less than: a < b
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
These conditions can be used in several ways, most commonly in "if statements"
and loops.
An "if statement" is written by using the if keyword.
Example If statement:

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

7. Conditional Statements
• If-Else Structure:

if age >= 18:


print("Adult")
else:
print("Minor")

• Logical operators: and, or, not.

8. Loops
• For Loop: Iterates over sequences.

for i in range(5):
print(i)

End of Revision

You might also like