0% found this document useful (0 votes)
8 views2 pages

Python Assignment 9

Uploaded by

sirohiriya5191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Python Assignment 9

Uploaded by

sirohiriya5191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Worksheet - 9

Q1. Write a Python program to check if 'apple' is present in the list fruits = ['apple',
'banana', 'cherry'] using membership operator.

Q2. Use identity operator to check if two variables x = [1,2,3] and y = [1,2,3] point to the
same object in memory. And check if x and y are equal.

Q3. Write a Python program that checks if 'a' is not in the string s = 'hello world'.

Q4. Use identity operators to verify if two variables x = 5 and y = 5 are the same object.
If no then support your answer with the reason why they are not the same object.

Q5. Write a Python program to test membership of key 'name' in the dictionary person =
{'name':'John', 'age':25}.

Q6. Convert numbers from 0 to 15 into binary numbers. (Fill the table)

Number 8 4 2 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Q7. Convert binary numbers into decimal numbers (0–32). (Fill the table)

Binary Number Number

1011

1100

10011

0011

1010

10110

10001

10111

1111

0100

11111

11000

10010

00101

1101

100000

You might also like