Python : Conditional Statement Test 3

 

Python : Conditional Statement Test 3

Q1. Write a program to check a year is leap year 

    or not.

Q2. Write a program to check whether a person is

    eligible for voting or not.(voting age >=18)

Q3. Write a program to check whether a person is 

    senior citizen or not.

Q4. Write a program to find the lowest number out 

    of two numbers excepted from user.

Q5. Write a program to find the largest number out

    of two numbers excepted from user.

Q6. Write a program to check whether a number 

    (accepted from user) is positive or negative.

Q7. Write a program to check whether a number is 

    even or odd.

Q8. Write a program to display the spell of a 

    digit accepted from user (like user input 0 

    and display ZERO and so on)

Q9. Write a program to whether a number (accepted 

    from user) is divisible by 2 and 3 both.

Q10. Write a program to find the largest number 

     out of three numbers excepted from user.

Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test Part 3

Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test  Part 3


Q1. Can we add new values in an existing dictionary?
Q2. Write a code to add the following key-value to a given dictionary.
    a = {'Class':'VI','Sec':'B','Rollno' : 1}
    
        
Q3. Can we do modification in existing key value pair?

Q4. Write the code to change the class of given
dictionary to 'VII'
a = {'Class':'VI','Sec':'B','Rollno' : 1}

Q5. What do you mean by update() in context of
dictionary in python
   
Q6. What is the difference between del command and pop() 
     function in dictionaries?

Q7. Write the output of the following:
    a = {'Class':'VI','Sec':'B','Rollno' : 1}
    print('Class' in a)
    print('sec' in a)

Q8. Can there be any dictionary without key or
without value?if yes then give example.

Q9. Which function return the count of
    key-value pairs in the given dictionary.

Q10. Which function removes all the items from
    dictionary?


Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test Part 2

                              

Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test  Part 2


Q1. Name a function which is used to create an empty dictionary.

Q2. What empty curly braces({}) shows in python?


Q3. Write the output of the following: 

        a = {}
        a[1]='A'
        a[2]='B'
        a[3]='C'
        print(a)

Q4. Write the output of the following:
        a = {'Class':'VI','Sec':'B','Rollno' : 1}
        print(a)
        print(a['Class'])
        print(a['Sec'])
        print(a['roll'])
if any of the above print statement return an error
than identify the error type.

Q5. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(i)

Q6. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(a)

Q7. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(a[i])

Q8. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
      print(a[i])
    print(a[i])

Q9. What type of error shows by the following program:
    a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in len(a):
    print(a[i])
Q10. What do you mean by traversing a dictionary?

Solution:

Q1. Name a function which is used to create an empty dictionary.

Ans. dict()

Q2. What empty curly braces({}) shows in python?

Ans. Curly braces shows empty dictionary in python.


Q3. Write the output of the following: 

        a = {}
        a[1]='A'
        a[2]='B'
        a[3]='C'
        print(a)
Ans. {1 : 'A', 2 : 'B', 3 : 'C'}

Q4. Write the output of the following:
        a = {'Class':'VI','Sec':'B','Rollno' : 1}
        print(a)
        print(a['Class'])
        print(a['Sec'])
        print(a['roll'])
if any of the above print statement return an error
than identify the error type.
Ans. {'Class': 'VI', 'Sec': 'B', 'Rollno': 1}      VI B
Last print statement will show "key error" as 'roll' key
is not there in dictionary

Q5. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(i)
Ans. Class
Sec
Rollno

Q6. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(a)
Ans. {'Class':'VI','Sec':'B','Rollno' : 1}
{'Class':'VI','Sec':'B','Rollno' : 1}
{'Class':'VI','Sec':'B','Rollno' : 1}

Q7. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
    print(a[i])
Ans. VI
B
1

Q8. a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in a:
      print(a[i])
    print(a[i])
Ans. VI
B
1
1

Q9. What type of error shows by the following program:
    a = {'Class':'VI','Sec':'B','Rollno' : 1}
    for i in len(a):
    print(a[i])
Ans. TypeError: 'int' object is not iterable
Q10. What do you mean by traversing a dictionary?
Ans. Traversing a dictionary means accessing each element of
dictionary. This can be done by using for loop.

Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test Part 1

Computer Science - Informatics Practices Class XI/XII Python Dictionary Solved Test  Part 1

Q1. Is dictionary in python is a collection or a sequence?

Q2. What do you mean by dictionary in python?

Q3 In dictionary we have _________ value concept.

Q4, In dictionary , key and it's value are separated by ________.

Q5. Entire dictionary is enclosed in _______ braces

Q6. Dictionary is _________(mutable/immutable)

Q7. The ______ of dictionary can be of any type but the _______ must be of immutable type.

Q8. Each key is associated with value.(T/F)

Q9. Write the code to create empty dictionary named 'd'

Q10. Write the output of the following:

            >>> a = {}

            >>>print(type(a))


Solution:

Q1. Is dictionary in python is a collection or a sequence?

Ans : Collection

Q2. What do you mean by dictionary in python?

Ans : Python dictionary is an unordered collection of items where each item is a KEY-VALUE pair

Q3 In dictionary we have _________ value concept.

Ans. Key

Q4, In dictionary , key and it's value are separated by ________.

Ans. colon(:)

Q5. Entire dictionary is enclosed in _______ braces

Ans. Curly -{ }

Q6. Dictionary is _________(mutable/immutable)

Ans. mutable

Q7. The ______ of dictionary can be of any type but the _______ must be of immutable type.

Ans 7- values, key

Q8. Each key is associated with value.(T/F)

Ans. True

Q9. Write the code to create empty dictionary named 'd'

Ans. d={ }

Q10. Write the output of the following:

            >>> a = {}

            >>>print(type(a))

Ans. <class 'dict'>

Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 10

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 10

Q1. Write a program to input a number and count the occurrence of that number in the given list.

       B = [34,21,3,12,34,56,76,5,4,21,12,34]

Q2. Write a program to separate the character and numeric value from a given list and store them in a separate list.

    A = [1,’f’,2,’b’,3,4,’h’,j’,6,9,0,’k’]

Q3. What do you mean by sorting?

Q4. Name any two sorting techniques.

Q5. Write a program to create a list of 10 integers and sort the list in increasing order using bubble sort.

Q6. Suppose total element in a list are 7, so how many times the outer loop will be executed in bubble sort.

Q7. A = [23,45,21,78,43]

Write the order of the elements in the above list after first pass of bubble sort (in ascending order).

Q8. Write any one application of bubble sort.

Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 9

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 9

Q1. Write a program to check whether a number (accepted from user) is present in a list.

Q2. Name a function which is used to find the largest number from a list.

Q3. ______ function returns the smallest value from the list.

Q4. max() function works in a list which have all values of same data type. (T/F)

Q5. Write the full form of ASCII value.

Q6. ASCII value of ‘A’ is ______.

Q7. ASCII value of ‘b’ is ______.

Q8. Write the output of the following:

a = [11,42,31,14]

print(max(a))

print(min(a))

print(a.index(42))

 

 Q9. Write the output of the following:

a = [11,42,31,'a',14]

print(max(a))

 

Q10. Write the output of the following:

a = ['amit','Amit','Amita']

print(max(a))

print(min(a))

 

 

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 8

 

Computer Science - Informatics Practices Class XI/XII Python List Solved Test  Part 8

Q1. Explain the following functions in reference to list with example

a.     count()

b.     clear()

c.     pop()

d.     remove()

Q2. What is the difference between del statement and pop() function.

Q3. Write the output of the following:

       

Q4. Out of del and pop() which one return the deleted element.

Q5. remove() function take _______ (element/index) as argument.

Q6. Name a function/statement which can delete more than one element from the list.

Q7. Name a function which can delete only one element from the list.

Q8. Write a program to delete/remove all the negative elements from the list.

Q9. Write a program to delete/remove all the odd numbers from the list.

Q10. Write a program to delete/remove all the numbers less than 10 from the list.

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet