Class 6th - Introduction To Python
Class 6th - Introduction To Python
Introduction
Python
Web
Applications
Business GUI-based
Applications Desktop
Applications
Python
Applications
Audio/Video Image
based Processing
Applications Applications
3D CAD
Applications
Starting Python
Modes in Python
Python IDLE provides two separate ways or modes to write and run Python programs.
These are:
Interactive mode/Immediate mode/Shell mode
Script mode/Editor mode
Interactive Mode
In this mode we write a single line of Python code and immediately see the results.
For example, type print (“Hello Everyone”) at the prompt and press Enter key. You
will see the output immediately as shown in Fig 3.
Closing Python
Variable in Python
Variables are named storage locations where data is stored temporarily during program
execution. Values of variables can be changed during program run.
Rules for naming a variable:
The type of value that a variable holds is called its datatype. Following data types are
used in Python:
Integer
The integer data type contains positive or negative whole numbers with no decimal
point.
For example, A = 10, age = 15, b = -9
Float
The float data type represents real numbers and it is written with a decimal point.
For example, c = 4.5, x = 23.45
String
A string is a collection of characters enclosed in single quotes (‘ ’), double quotes (“ ”)
or triple quotes (‘‘‘ ’’’)
For example, name = “Sunil Khanna”, K = ‘hello’
Boolean
Boolean values are True and False. True is 1 and False is 0.
For example, s = 5 > 8, it will print false.
Practice Time
In Python, print () function is used to display an output on screen. It can also be used
for calculations, such as
Smart Tip
print(5+7)
Python is a case-
sensitive language. So,
Print() is invalid whereas
print() is valid command
Practice Time
Open Python in Shell mode and type the following commands. Write the output in given
space.
(a) 6 * 3 – 5 _______
(b) 40 / (20 – 16) * 2 _______
(c) 8 * (4 + 7) _______
(d) 13 + 7 – 3 * 4 – 2 _______
The input () function is used to accept input from keyboard. This function takes the
value from the keyboard as a string argument.
Program – 1: A program to demonstrate the use of input() function.
Do You Know
Int() or float() function is used along with the input() function to convert
strings into integers or float values.
Practice Time
C Short Answers