0% found this document useful (0 votes)
19 views5 pages

Python Notes

Python notes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
19 views5 pages

Python Notes

Python notes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

PODAR INTERNATIONAL SCHOOL (CAMBRIDGE)

Cambridge Assessment International Education


“SARASWATI” BEHIND ARCADIA, HIRANANDANI ESTATE, PATLIPADA, THANE (WEST) - 400607

Python Notes

Ques1. Explain the relational operator used for checking the condition?

Relational operators compare the values. It either returns True or False according to the condition.

Ques2. What is meant by conditional If?

The if statement in python is used to test a condition. If condition is true, statement of if block is
executed otherwise it is skipped. Syntax of python if statement:

if(condition):

statements

Ques3. What is meant by conditional If and else?

When the condition is true, then code associated with if statement will execute, otherwise code
associated with else statement will execute.

1 Python Notes /VII ICT /24-25


PODAR INTERNATIONAL SCHOOL (CAMBRIDGE)
Cambridge Assessment International Education
“SARASWATI” BEHIND ARCADIA, HIRANANDANI ESTATE, PATLIPADA, THANE (WEST) - 400607

Example:

a=10

b=20

if a>b:

print(“a is greater”)

else:

print(“b is greater”)

Ques4. What is conditional statement used to check multiple values?

To check for multiple conditions elif Statement is used. This statement is like executing a if
statement inside a else statement.

Syntax:

If statement:

statements

elif statement:

statements

else:

statements

Ques5. Write a few methods that are used in Python Lists.

a) append()- add an element to end of list

b) insert()- insert an item at the defined index

c) remove()- removes an item from the list

d) clear()- removes all items from the list

e) reverse()- reverse the order of items in the list

Ques 6. Explain input command in python with suitable example.

The input () is a built-in function in python that retrieves the input from the user.

Example:

2 Python Notes /VII ICT /24-25


PODAR INTERNATIONAL SCHOOL (CAMBRIDGE)
Cambridge Assessment International Education
“SARASWATI” BEHIND ARCADIA, HIRANANDANI ESTATE, PATLIPADA, THANE (WEST) - 400607

name = input("Please Enter Your Name: ")

id= input("Please Enter Your Employee ID: ")

print("Name & Id: ", name, id)

Ques 7. Explain the Python list.

 List is a collection of elements which is ordered and changeable (mutable).


 Allows duplicate values.
 A list contains items separated by commas and enclosed within square brackets ([ ]).
 All items belonging to a list can be of different data type.

Ques 8. Describe the following

(i) Creating the list

(ii) Accessing values in the lists

(iii) Adding an item to the list

(iv) Deleting the list elements

Accessing lists:

The values stored in a list can be accessed using the slice operator ([ ]) with indexes.

3 Python Notes /VII ICT /24-25


PODAR INTERNATIONAL SCHOOL (CAMBRIDGE)
Cambridge Assessment International Education
“SARASWATI” BEHIND ARCADIA, HIRANANDANI ESTATE, PATLIPADA, THANE (WEST) - 400607

The first item in the list has the index zero (0).

Example :

list1 = ['physics', 'chemistry', 1997, 2000];

list2 = [1, 2, 3, 4, 5, 6, 7 ];

print ("list1[0]: ", list1[0])

Adding an item to the list

you can add to elements in a list with the append() method.

Example :

thislist = ["apple", "banana", "cherry"]

thislist.append("orange")

print(thislist)

or

Insert Items :

The insert() method inserts an item at the specified index:

Example :

thislist = ["apple", "banana", "cherry"]

thislist.insert(1, "orange")

print(thislist)

Deleting the list elements

Remove Specified Item:

4 Python Notes /VII ICT /24-25


PODAR INTERNATIONAL SCHOOL (CAMBRIDGE)
Cambridge Assessment International Education
“SARASWATI” BEHIND ARCADIA, HIRANANDANI ESTATE, PATLIPADA, THANE (WEST) - 400607

The remove() method removes the specified item.

Example :

thislist = ["apple", "banana", "cherry"]

thislist.remove("banana")

print(thislist)

or

Remove Specified Index

The pop() method removes the specified index.

Example
thislist = ["apple", "banana", "cherry"]

thislist.pop(1)

print(thislist)

or

Remove the last item:

thislist = ["apple", "banana", "cherry"]

thislist.pop()

print(thislist)

5 Python Notes /VII ICT /24-25

You might also like