Search Header Logo
Python _ IX

Python _ IX

Assessment

Presentation

Other

9th Grade

Practice Problem

Hard

Created by

SUNAYANA R

Used 16+ times

FREE Resource

56 Slides • 10 Questions

1

media

PYTHON

2

media

3

media

PYTHON FOR AI

4

media

5

media

DOWNLOADING PYTHON

6

media

PYTHON IDLE INSTALLATION

7

media

8

media

9

media

10

media

11

media

12

Fill in the Blank

Python can be executed in _________ modes.

13

media

PYTHON COMMENTS

A comment is text that doesn't affect the outcome of a code, it is just a

piece of text to let someone know what you have done in a program or
what is being done in a block of code.

14

Fill in the Blank

#is an example of __________ line comment in Python

15

media

PYTHON KEYWORDS AND

IDENTIFIERS

16

media

17

Multiple Select

Pick the keywords in Python

1

While

2

print

3

input

4

true

18

media

VARIABLES

A variable is a named location used to store data in the memory.

It is helpful to think of variables as a container that holds data which can be

changed later throughout programming.

19

media

VARIABLE NAMING CONVENTIONS

20

Multiple Choice

An identifier cannot start with a digit.

1

True

2

False

21

media

ASSIGNING VALUE TO A VARIABLE

Assignment operator is used in Python to assign values to variables.

For example, a = 5 is a simple assignment operator that assigns the value 5

on the right to the variable a on the left.

22

media

ARITHMETIC OPERATORS

23

Multiple Choice

Integer division operator in Python is ____________

1

//

2

\\

3

/

4

%

24

media

PYTHON INPUT AND OUTPUT

We use the print() function to output data to the standard output device
(screen).

In python, input() function is used to take user’s input in the program.

25

media

PYTHON DATATYPES

26

media

NUMBERS DATATYPE

Integer & Long Integer

Range of an integer in Python can be from -2147483648 to 2147483647, and

long integer has unlimited range subject to available memory.

Integers are the whole numbers consisting of + or – sign with decimal digits

like 100000, -99, 0, 17.

While writing a large integer value, don’t use commas to separate digits.

Also, integers should not have leading zeros.

Floating Point

Numbers with fractions or decimal point are called floating point numbers. A

floating-point number will consist of sign (+,-) sequence of decimals digits
and a dot such as 0.0, -21.9, 0.98333328, 15.2963.

27

media

SEQUENCE DATATYPE

A sequence is an ordered collection of items, indexed by positive integers.

It is a combination of mutable and non-mutable data types.

Three types of sequence data type available in Python are:

a) String

b) Lists

c) Tuples

28

media

MUTABLE VS IMMUTABLE

29

media

ORDERED VS UNORDERED

30

media

STRING

String is an ordered sequence of letters/characters.
They are enclosed in single quotes (‘ ‘) or double (“ “).
The quotes are not part of string.
They only tell the computer where the string constant begins and ends.
They can have any character or sign, including space in them.

31

media

LISTS

Lists List is also a sequence of values of any type.

Values in the list are called elements / items.

These are indexed/ordered. List is enclosed in square brackets.

Example:

32

media

TUPLES

Tuples are a sequence of values of any type, and are indexed by integers.

They are immutable. Tuples are enclosed in ().

33

media

SETS

Set is an unordered collection of values, of any type, with no duplicate entry.

34

media

DICTIONARIES

Dictionary is an unordered collection of key-value pairs.

It is generally used when we have a huge amount of data.

35

media

36

Multiple Choice

dob = [19,"January",1990] is an example of _____________ in Python.

1

Tuple

2

Set

3

Dictionary

4

List

37

Multiple Choice

x= (5, 'program', 2.5) is an example of ____________ in Python

1

List

2

Tuple

3

Set

38

media

Type Conversion

The process of converting the value of one data type

(integer, string, float, etc.) to another data type is called
type conversion.


Python has two types of type conversion.

.
1.Implicit Type Conversion



2. Explicit Type Conversion

39

media

Implicit type conversion

Python automaticall.y converts one data type to another data type.

40

media

Explicit type conversion (Type casting)

In Explicit Type Conversion, users convert the data type of an object to
required data type. We use the predefined functions like int(), float(),
str(), etc to perform explicit type conversion

41

media

List Methods


Creating a list:

In Python programming, a list is created by placing all the items (elements)
inside a square bracket [ ], separated by commas

42

media

Nested List


Note:

A list can also have another list as an item. This is called nested lists.

43

media

Accessing a list


List Index

A list index is the position at which any element is present in the list. Index in
the list starts from 0


Negative Indexing

Python allows negative indexing for its sequences. The index of -1 refers to the
last item, -2 to the second last item and so on.

44

Multiple Choice

day = ['f','r','i','d','a','y']

print(a[-1])

What will be the output of the above code ?

1

f

2

y

3

r

4

a

45

media

Adding elements to a list


We can add an element to any list using two methods :

1)

Using append()

Only one element at a time can be added to the list by using append()
method at the end of the list.

2) Using insert()

For addition of element at the desired position, insert() method is used.

3) Using extend() method

This method is used to add multiple elements at the same time at the end of
the list.

Note: extend() method won't work with a single object.

46

media

Append method

47

media

Extend method

48

media

Insert method


Python List insert() method inserts an item at a specific index in a list.

49

Multiple Choice

For addition of an element at a desired position in a list ___________ method is used.

1

append

2

extend

3

insert

50

media

Removing Elements from a List


Elements from a list can removed using two methods :

1) Using remove() method

Remove method in List will only remove the first occurrence of the searched
element.

2) Using pop() method

Pop() function can also be used to remove and return an element from the
set, but by default it removes only the last element of the set, to remove an
element from a specific position of the List, index of the element is passed as
an argument to the pop() method.

51

media

52

Multiple Choice

The remove() removes all occurances of the searched element from the list .

1

False

2

True

53

media

Slicing of a List


Slicing is done in a string to obtain sub-strings of the original string

54

media

Sorting


The sort() method by default sorts elements in ascending order.

55

media

Basic Python Program


Write a python program to accept an employee’s name and age and
display the same.


Write a python program to add two numbers and display the result.


Write a python program to accept the side of square and calculate its
area.

56

media

Flow of control

57

media

If Statement


The if statement is used to check a condition: if the condition is true, we run
a block of statements (called the if-block)

58

media

If else statement

59

media

Python if...elif...else Statement

60

media

Python Nested if

61

media

The For Loop


The for..in statement is another looping statement which iterates over a
sequence of objects i.e. go through each item in a sequence.

62

media

Example: Python for Loop

63

media

The while Statement


The while statement allows you to repeatedly execute a block of
statements as long as a condition is true.

64

media

65

media

CONCEPT MAP

Introduction to

python

Applications

Lists

Datatypes

Installation

Features

66

media

ASSIGNMENT

Q1) What are the key features of python ? Mention various applications along
with it

Q2) What are the different modes for coding in python?

Q3) What are comments in python ? List down the various types of comments.

Q4) What are the rules for naming of variables and constants

Q5) Explain python input and output with the help of an example.

Q6) Explain the insert method in list using an example.

Q7) Write the syntax of for and while loop.

Q8) What is negative indexing ? Explain with an example.

media

PYTHON

Show answer

Auto Play

Slide 1 / 66

SLIDE