0% found this document useful (0 votes)
6 views5 pages

Gr7 Notes Python Programming

This document provides an overview of Python programming for Grade 7 students, covering key concepts such as the importance of programming, the use of the print() function, data types, and variables. It includes learning objectives, examples, and activities to reinforce understanding of Python basics. The document also introduces the input() function for user interaction.
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)
6 views5 pages

Gr7 Notes Python Programming

This document provides an overview of Python programming for Grade 7 students, covering key concepts such as the importance of programming, the use of the print() function, data types, and variables. It includes learning objectives, examples, and activities to reinforce understanding of Python basics. The document also introduces the input() function for user interaction.
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

Department of Computer Science

Class: Grade 7
Lesson: Python Programming-notes

Session 1: Introduction
Learning Objectives:
• Explain the importance and purpose of programming in real life situations.
• Describe the uses of the print() in Python.
• Write simple Python programs using print().
Keywords:
1. Programming language
2. IDLE
3. Python Shell
4. Interactive mode
5. Script mode
6. print()
7. input()
8. variables
9. datatypes
10. Syntax error
11. Prompt - >>>

What is Python?
➢ Python is a high-level programming language.
➢ It was created by Guido van Rossum and was first released on February 20,1991.
➢ It was named after comedy group ‘Monty Python’.

Features of Python:
➢ Python is a high-level programming language.
➢ It is an open-source language.
➢ It runs well on different platforms (Windows, Linux and Macintosh). So, it is a
portable language.
➢ Python is a case-sensitive language.
➢ It is an interpreted language (i.e) it executes the code line-by-line.
➢ The python program is saved as .py extension.

Python IDLE – IDLE stands for Integrated Development and Learning Environment. IDLE is a
graphic-based development environment for Python which is used to create, edit, and
debug programs.
Interactive Mode vs Script mode
Two ways of using python interpreter

Interactive mode Script mode


Suitable for small programs and for Suitable for large programs and for
beginners experts
Code cannot be saved Code can be saved
We get output for every single line of Entire program is first compiled and then
code executed.

What is print()?
The print() function is used to display information to the user.
Syntax:
print(“message”)
Example:
print(“Welcome”)
print(“5+3”)
print(5+3)

Syntax Error:
Syntax error occurs when we break the rules of programming language.
Example: print("Welcome)

AFL/Class Activity:

Predict the Output


Code Output
print(“Hello World”)
print(5)
print(“5+3”)
print(5+3)
print(“Sum of 5 and 3 is”,5+3)
Code Debugging
PRINT(“I love coding”)
Print(“United Arab Emirates)

Lab Activity:
1. Write a Python program to display your profile using the print() function.
2. Write a Python program to print a pattern using the print() function.
3. Write a Python program to generate a supermarket bill using the print() function.

Session 2: Datatypes and Variables


Learning Objectives:
1. Define the purpose of variables and how to create and assign a value to a variable.
2. Explain different data types (int, float, str)in Python

Data Types:
A data type specifies the type of value a variable can contain. We use the type() function to
check data type

Data Type Description Example


int (integer) Whole numbers(+ve or –ve) without decimals. 10, -20, 0
float Numbers that contain decimal point. 3.14, 1.0
str (string) Text or characters inside quotes "Hello“, “adis@2016”

What is a variable?
• A variable is like a container that stores information.
• We use variables to hold data that can be used or changed later in a program
How to create a variable?
We use the assignment operator (=) to give a value to a variable

Syntax:
variable_name = value
Example:
city=“Abu Dhabi”
name=“Sarah”
age=11
Rules for naming variables

Allowed Not Allowed

Must start with a letter or underscore (_) Cannot start with a number
Can contain letters, numbers, and
No spaces allowed
underscores
Are case-sensitive (age ≠ Age) No special symbols like @, #, $
Should have meaningful names Avoid single letters like a, b

AFL Activity: Circle the valid variable name. If invalid, state the reason.

Analyze the code and predict the output(HW):


Code 1: Code 2:
name="Sara" name="Sara"
grade=7 grade=7
school="ADIS" school="ADIS"
perc=97.5 perc=97.5
print(name) print("My name is",name)
print(grade) print("I am in class",grade)
print(school) print("I am a student of",school)
print(perc) print("I scored",perc,"in MID TERM Exam")
Code 3:
name="Sara"
grade=7
school="ADIS"
perc=97.5
print("My name is",name,"studying in
class",grade,"at",school,"school.","I secured",perc,"in MID-TERM Exam")
Lab Activity:
1. Complete the following Python program. Store your Name, Class, and School in three
different variables and print them.
2. Write a Python program to display the details of the UAE (capital, language and
currency) using variables and the print() function.
3. Python program to find the sum of 2 numbers(5,7)

Session 3: input()
Learning Objectives:
Describe the need for input() and explain how to get values from the user using
input().
What is input()?
input() is used to receive information from the user. By default, it always returns
string values.
Syntax:
Var_name=input(“String”)
Example:
name=input(“Enter your name:”)
age=int(input(“Enter your age:”))

Lab Programs:
1. Ask the user for their name and display a greeting message.
2. Library management program.
3. Python program to find the area and perimeter of a rectangle.

You might also like