Pythongrade 7
Pythongrade 7
VII
2024-2025
Page 1 of 11
What is a Programming Language?
Programming languages define and compile a set of instructions for the CPU (Central Processing
Unit) for performing any specific task. Every programming language has a set of keywords
along with syntax- that it uses for creating instructions.
Till now, thousands of programming languages have come into form. All of them have their own
specific purposes. All of these languages have a variation in terms of the level of abstraction
that they all provide from the hardware. A few of these languages provide less or no abstraction
at all, while the others provide a very high abstraction. On the basis of this level of abstraction,
there are two types of programming languages:
Low-level language
High-level language
The primary difference between low and high-level languages is that any programmer can
understand, compile, and interpret a high-level language feasibly as compared to the machine.
The machines, on the other hand, are capable of understanding the low-level language more
feasibly compared to human beings.
High-level languages use command words and Syntax which reflects everyday language, which
makes them easier to learn and use. High-level languages also offer the programmer
development tools such as libraries and built-in functions.
Examples of high-level programming languages in active use today include Python, JavaScript,
Visual Basic, Delphi, Perl, PHP, C#, Java and many others.
Page 2 of 11
Introduction to Python
In this introduction to programming using Python, we will explore various Real-World examples
to understand the basics of programming concepts. Students in grades 6 to 8 can better grasp the
fundamental ideas behind programming and its relevance in everyday life by relating
programming concepts to practical examples.
Variables:
What are Variables and Data types?
Variables, and data types, are fundamental concepts in Python. Variables are used to store data
values in memory for later use. Let's define each of these concepts
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
2myvar = "John"
my-var = "John"
my var = "John"
Data Types:
The data type is a classification that tells the computer what kind of data is being stored or used
in a program, such as numbers, text, or true/false values.
Page 3 of 11
Real-World Examples: Consider a school library. Different types of books are stored on
different shelves. In programming, data types are like different categories of information that we
can store and manipulate. Here are some common data types in Python:
Operators
Python language offers numerous operators to manipulate and process data. Following is the list
of some basic operator types. Here, we will discuss only two types of operators.
Assignment Operator
Arithmetic Operators
Logical Operators
Relational Operators
Assignment Operator
Assignment operator is used to assign a value to a variable, or assign value of variable to another
variable.
Equal sign (=) is used as assignment operator in Python. Consider the following example
Example:
sum = 5
Value 5 is assigned to a variable named sum after executing this line of code.
Arithmetic Operators
Arithmetic operators are used to perform arithmetic operations on data. Following table
represents arithmetic operators with their description.
Arithmetic Table
Page 4 of 11
Operator Name Description
It is used to divide the value on the left
/ Division Operator
side by the value on right side
* Multiplication Operator It is used to multiply two values
Page 5 of 11
Page 6 of 11
Python Program to Convert Kilometers to Miles
Page 7 of 11
Page 8 of 11
Python Program to Convert Celsius to Fahrenheit
Page 9 of 11
Python Program to check if a Number is Positive, Negative or 0
A number is positive if it is greater than zero. We check this in the expression of if. If it is False,
the number will either be zero or negative. This is also tested in subsequent expression.
Page 10 of 11
Python Program to check if a Number is odd or even
A number is even if it is perfectly divisible by 2. When the number is divided by 2, we use the
remainder operator % to compute the remainder. If the remainder is not zero, the number is odd.
Page 11 of 11