Review of Python Basics || Preeti Arora || Class 12 || Unsolved Question || Computer science || Solution



Q 1 = What are the advantages of Python programming language?



Q 2 = In how many different ways can you work in Python?



Q 3 = What are the advantages/disadvantages of working in interactive mode in Python?



Q 4 = Write Python statement for the following in interactive mode:
(a) To display sum of 3, 8.0, 6*12
(b) To print sum of 16, 5.0, 44.0




Q 5 = What are operators? Give examples of some unary and binary operators.



Q 6 = What is an expression and a statement?



Q 7 = What all components can a Python program contain?



Q 8 = What are variables? How are they important for a program?



Q 9 = Write the output of the following:

(i)
for i in '123':
    print("guru99", i)

(ii)
for i in [ 100, 200, 300] :
    print(i)

(iii)
for j in range (10, 6, -2):
    print (j * 2)

(iv)
for x in range (1, 6):
    for y in range (1, x+1) :
        print (x,' ', y )

(v)
for x in range (10, 20):
    if (x == 15):
        break
    print (x)

(vi)
for x in range (10, 20) :
    if (x % 2 == 0) :
        continue
    print (x)





Q10 = Write the output of the following program on execution if x = 50:

if x > 10 :
    if x > 25 :
        print("ok")
    if x > 60 :
        print("good")
elif x > 40 :
    print("average")
else:
    print("no output")




Q 11 = What are the various ways of creating a list?



Q 12 = What are the similarities between strings and lists?




Q 13 = Why are lists called a mutable data type?




Q 14 = What is the difference between insert() and append() methods of a list.



Q 15 = Write a program to calculate the mean of a given list of numbers.



Q 16 = Write a program to calculate the minimum element of a given list of numbers.



Q 17 = Write a code to calculate and display total marks and percentage of a student from a given list storing the marks of a student.




Q 18 = Write a Program to multiply an element by 2 if it is an odd index for a given list containing both numbers and strings.



Q 19 = Write a Program to count the frequency of an element in a given list.



Q 20 = Write a Program to shift elements of a list so that the first element moves to the second index and second index moves

to the third index, and so on, and the last element shifts to the first position.

Suppose the list is [10, 20, 30, 40]
After shifting, it should look like: [40, 10, 20, 30]




Q 21 = A list Num contains the following elements:
3, 25, 13, 6, 35, 8, 14, 45
Write a function to swap the content with the next value divisible by 5 so that the resultant list will look like:
25, 3, 13, 35, 6, 8, 45, 14




Q 22 = Write a program to accept values from a user in a tuple. Add a tuple to it and display its elements one by one. Also display its maximum and minimum value.



Q 23 = Write a program to input any values for two tuples. Print it, interchange it and then compare them.



Q 24 = Write a Python program to input 'n' classes and names of their class teachers to store them in a dictionary and display

the same. Also accept a particular class from the user and display the name of the class teacher of that class.




Q 25 = Write a program to store student names and their percentage in a dictionary and delete a particular student name from

the dictionary. Also display the dictionary after deletion.




Q 26 = Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number,

etc., store them in a dictionary and display all the details in a tabular form.




Q 27 = Write a Python program to capitalize first and last letters of each word of a given string.



Q 28 = Write a Python program to remove duplicate characters of a given string.



Q 29 = Write a Python program to compute sum of digits of a given string.



Q 30 = Write a Python program to find the second most repeated word in a given string.



Q 31 = Write a Python program to change a given string to a new string where the first and last chars have been exchanged.



Q 32 = Write a Python program to multiply all the items in a list.



Q 33 = Write a Python program to get the smallest number from a list.



Q 34 = Write a Python program to append a list to the second list.



Q 35 = Write a Python program to generate and print a list of first and last 5 elements where the values are square of numbers

between 1 and 30 (both included).




Q 36 = Write a Python program to get unique values from a list.



Q 37 = Write a Python program to convert a string to a list.



Q 38 = Write a Python script to concatenate the following dictionaries to create a new one:

d1 = {‘A’: 1, ‘B’: 2, ‘C’: 3}
d2 = {‘D’: 4}

Output should be:
{‘A’: 1, ‘B’: 2, ‘C’: 3, ‘D’: 4}




Q 39 = Write a Python script to check if a given key already exists in a dictionary.



Q 40 = Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values

are square of keys.

Sample Dictionary
{1:1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225}




Q 41 = Write a Python script to merge two Python dictionaries.



Q 42 = Write a Python program to sort a dictionary by key.



Q 43 = Write a Python program to combine two dictionary adding values for common keys.

d1 = {'a': 100, 'b': 200, 'c': 300}
d2 = {'a': 300, 'b': 200, 'd': 400}

Sample output:
Counter ({'a': 400, 'b': 400, 'c': 300, 'd': 400})



Q 44 = Write a Python program to find the highest 3 values in a dictionary.



Q 45 = Write a Python program to sort a list alphabetically in a dictionary.



Q 46 = Write a Python program to count number of items in a dictionary value that is a list.



Q 47 = Consider the following unsorted list: 105, 99, 10, 43, 62, 8. Write the passes of bubble sort for sorting the list in

ascending order till the 3rd iteration.




Q 48 = What will be the status of the following list after the First, Second and Third pass of the insertion sort method used for

arranging the following elements in descending order?
28, 44, 97, 34, 50, 87
Note: Show the status of all the elements after each pass very clearly underlining the changes.

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post