Chapter - 6
Introducing
Python
Part-B
Objectives
🟃 Working in Script mode
❖Create program
❖Run a program
🟃 Data Types
❖Integer
❖Float
❖String
🟃 Input Function
🟃 Print Function
🟃 Recap
Working in Script
mode
For writing lengthy programs in Python, Script
mode is used. Using this mode, we can create and
edit Python programs. In this mode, we can save
our file so that it can be used later. The complete
script is written in an editor, such as a Notepad in
Windows.
Step-1: File New
🡪
Step-2: The new
Script mode opens
Step-3: Type the
python program
Step-4: Save the
python program
.py is the
extension for
PYTHON files.
Step-5: Run Run
🡪
Module or Press
function key F5
Step-6: The output in
interactive mode
Script
Mode
Interactive
Mode
1. Write a program to print your hobbies. (any two, in two different
lines.)
2. Write a program to print the 4 item’s total price. (The items can
be fruits, books, mobile, pizza etc.)
3. Write a program to print three subject’s total marks and
average.
String Data
type
Date Data type
int Data type
int float str
int
long int
(Older version)
bool
Stores a
number with
out decimal
number
long int
(Older version)
It represents
logical value True
means 1, False
means 0
Data Types
Assignment – Write the data type for the
following values.
1. 56
2. 89.25
3. Name
4. 7>3
5. Two
6. ‘67.89’
7. Age>=18
8. 0
9. 15-Aug-2020
10.function
input() function
⮚ Input function is used to accept the
value for a variable from the user. To
input integer and float values, we
can use int() or float() along with
input().
⮚ In python, input() function takes
one string argument. This means
that whatever values is being
entered by the user, it will be taken
as a string argument.
It doesn’t display
sum rather the
numbers are
displayed together
and are printed as
string.
Write a Python program to read school name and
grade, display in which grade he/she will be studying
after two years.
Then
how do
we
do?????
It is displaying sum.
As the int function
has converted
string to integer.
Thus addition is
possible.
int function is used to
convert string to integer
value.
Program to swap two numbers
1. Write a program to calculate 5% discount on total purchase of
stationery.
2. Write a program to convert miles into kilometers.
1mile=1.6 km
3. Write a program to convert temperature from Fahrenheit to Celsius.
Celsius=(Fahrenheit-32) * 5/9
Features of print() function
🞇The print() function in python is used to print
a message or value on the output device.
🞇It converts the message or an object into a
string before writing it on the screen.
🞇It can have multiple parameters.
🞇It supports multiple escape sequences to
format the output,
eg., ‘n’- new line
‘t’ – tab space
‘r’ – carriage return.
Comma operator as separator in print
function.
Comma
operator
Comma
operator
Comma
operator
Tab space, new line and carriage return.
int () and float() functions are used to convert string to integer or float
value.

Grade 7- Introducing Python- Part-2 python data typesx

  • 1.
  • 2.
    Objectives 🟃 Working inScript mode ❖Create program ❖Run a program 🟃 Data Types ❖Integer ❖Float ❖String 🟃 Input Function 🟃 Print Function 🟃 Recap
  • 3.
    Working in Script mode Forwriting lengthy programs in Python, Script mode is used. Using this mode, we can create and edit Python programs. In this mode, we can save our file so that it can be used later. The complete script is written in an editor, such as a Notepad in Windows. Step-1: File New 🡪
  • 4.
  • 5.
    Step-3: Type the pythonprogram Step-4: Save the python program .py is the extension for PYTHON files.
  • 6.
    Step-5: Run Run 🡪 Moduleor Press function key F5 Step-6: The output in interactive mode Script Mode Interactive Mode
  • 7.
    1. Write aprogram to print your hobbies. (any two, in two different lines.) 2. Write a program to print the 4 item’s total price. (The items can be fruits, books, mobile, pizza etc.) 3. Write a program to print three subject’s total marks and average.
  • 8.
    String Data type Date Datatype int Data type
  • 9.
    int float str int longint (Older version) bool Stores a number with out decimal number long int (Older version) It represents logical value True means 1, False means 0 Data Types
  • 10.
    Assignment – Writethe data type for the following values. 1. 56 2. 89.25 3. Name 4. 7>3 5. Two 6. ‘67.89’ 7. Age>=18 8. 0 9. 15-Aug-2020 10.function
  • 11.
    input() function ⮚ Inputfunction is used to accept the value for a variable from the user. To input integer and float values, we can use int() or float() along with input(). ⮚ In python, input() function takes one string argument. This means that whatever values is being entered by the user, it will be taken as a string argument.
  • 12.
    It doesn’t display sumrather the numbers are displayed together and are printed as string.
  • 13.
    Write a Pythonprogram to read school name and grade, display in which grade he/she will be studying after two years. Then how do we do?????
  • 14.
    It is displayingsum. As the int function has converted string to integer. Thus addition is possible. int function is used to convert string to integer value.
  • 15.
    Program to swaptwo numbers
  • 16.
    1. Write aprogram to calculate 5% discount on total purchase of stationery. 2. Write a program to convert miles into kilometers. 1mile=1.6 km 3. Write a program to convert temperature from Fahrenheit to Celsius. Celsius=(Fahrenheit-32) * 5/9
  • 17.
    Features of print()function 🞇The print() function in python is used to print a message or value on the output device. 🞇It converts the message or an object into a string before writing it on the screen. 🞇It can have multiple parameters. 🞇It supports multiple escape sequences to format the output, eg., ‘n’- new line ‘t’ – tab space ‘r’ – carriage return.
  • 18.
    Comma operator asseparator in print function. Comma operator Comma operator Comma operator
  • 19.
    Tab space, newline and carriage return.
  • 20.
    int () andfloat() functions are used to convert string to integer or float value.