`Results`

` - `

` #1 If s is a set having elements s={1,2,3,4,5,6}, what would be the output of the above program ?`

` `

` ` 2 3 5

` ` 2 4 6

` ` 1 1 1

**Explanation-**

**for loop iterates over set s, and it first stores values in item variable**

**if checks whether 1 % 2 which is equal to 1 **

**And Python treats non-zero numbers as True then it prints value of item which is 1**

**if checks whether 2 % 2 which is equal to 0**

**And Python treats zero as False and control does not enter in if block**

**if checks whether 3 % 2 which is equal to 1**

**And Python treats non-zero numbers as True then it prints value of item which is 3**

**if checks whether 4% 2 which is equal to 0**

**And Python treats zero as False and does not enter in if block**

**if checks whether 5% 2 which is equal to 1**

**And Python treats non-zero numbers as True then it prints value of item which is 5**

**if checks whether 2 % 2 which is equal to 0**

**And Python treats zero as False and does not enter in if block**

**Answer is **

**1 3 5**

` #2 If d is a dictionary having elements d={‘India’:’New Delhi’, ‘Germany’:’Berlin’, ‘France’:’Paris’, ‘Spain’:’Madrid’}, how will value ‘Berlin’ be accessed.`

` ` d[1]

` ` d[2]

` ` d['Germany']

## Click on the below link to see the explanation

## Dictionary in Python

` #3 A tuple in Python is`

` ` Mutable(Changeble)

` ` Immutable(Unchangeble)

## Click on the below link to see the explanation

## Tuples in Python

` #4 If t is a tuple having elements t=(1,2,3,4,5,6), how will element 5 be printed?`

` ` t[-2]

` ` t[4]

` ` t[5]

` ` t[-2] and [4]

` ` t[-2] and [5]

## Click on the below link to see the explanation

## Tuples in Python

` #5 If a nested list is a=[3,5,8,4,15,34,[5,8,[-4,-8],9,3], 8,9,[6,9],12,7], then how which index you will use to access element -8.`

` ` a[6][3][1]

` ` a[6][2][1]

` ` a[10]

` ` a[1][2][2]

**Click on the link to see the explanation**

**https://www.postnetwork.co/nested-lists-in-python/**

## Be the first to comment on "Python Quizzes"