THE CENTRAL SCHOOL GRADE 5
INTRODUCTION TO Python PROGRAMMING
Python is a high-level, interpreted programming language known for its
simplicity and readability.
**Guido van Rossum is the creator of python
Features of Python
➢ Simple & Easy: Python is a simple language & easy to learn.
➢ Free/open source: Everybody can use python without purchasing a
license.
➢ High-level language: When coding in Python, one need not worry about
low-level details.
➢ Portable: Python codes are Machine & platform-independent.
➢ Standard Library: Python standard library contains prewritten tools for
programming.
Applications
• To build graphic design applications and games
• To design web applications.
• To create business applications.
Programming in Python
Python allows you to work in two ways - Shell mode/Interactive mode and
Script mode.
Shell mode/Interactive mode:
➢In the Interactive mode, the code is executed line by line.
THE CENTRAL SCHOOL GRADE 5
Script mode:
➢In the Script mode, the code is written and saved in a file and later executed
to get the output.
Variables
Variables are used to store data values. A user is free to choose or assign a
name to a variable, but there are certain rules to be followed while defining the
name of a variable, failing which, the code may result to an error.
e.g: Marks = 70
Here Marks is a variable with assigned value 70.
Rules for naming a variable:
• The names must begin with a-z, A-Z or an underscore ( _ ).
• Since Python is case sensitive, a and A are two different variables.
• The variable name can be of any length, but it is recommended to keep it
short.
• The reserved keywords cannot be used as a variable name, for example: try,
pass, yield, class.
• No other special character is allowed except underscore (_).
• Except for the first character, the digits 0 to 9 are allowed in the variable
name.
For example, 1Priya is wrong, but Priya1 is correct.
Data types
Every value belongs to a specific data type in Python. Data type identifies the
type of data values a variable can hold.
Example: string, int, float, Boolean
THE CENTRAL SCHOOL GRADE 5
Operators
Operators are the special symbols that carry out arithmetic and logical
computations.
Arithmetic Operators:
THE CENTRAL SCHOOL GRADE 5
Python Programs
input() function: This function first takes the input from the user and
converts it into a string.
type() function: This function is used to determine the type of data.
print(type(9))
print(type(7.8))
print(type(7>5))
OUTPUT:
<class 'int'>
<class 'float'>
<class 'bool'>
THE CENTRAL SCHOOL GRADE 5
TASK:
1. Write a program that takes two numbers as input from the user and
prints their sum.
2. Prompt the user to enter the length and width of a rectangle.
Calculate and print the area of the rectangle.
3. Write a program to:
(a) Print the name of your school.
(b) Find the sum of 25 and 49.
(c) Find the product of any two numbers.
(d) Find the remainder of 25/3.
(e) Find the data type of 10 > 0.
****THE END****