120 solutions available
Question 1Assertion (A): Every small unit in a Python programming statement is termed as a token.Reasoning (R): Tokens are not interpreted but are an...
Question 2Assertion (A): The data type of a variable is taken according to the type of value assigned to it.Reasoning (R): Data types do not require...
Question 3Assertion (A): In Python, strings, lists and tuples are called Sequences.Reasoning (R): Sequence is referred to as an ordered collection of...
Question 4Assertion (A): break and continue are termed as Jump statements.Reasoning (R): Jump statements can only be used with looping constructs but...
Question 5Assertion (A): The conditional flow of control can be defined with the help of if statement.Reasoning (R): if statement executes one or...
Question 6Assertion (A): Indexing refers to accessing elements of a sequence. Python offers two types of indexing, viz. positive or forward and...
Question 7Assertion (A): Dictionaries in Python are mutable.Reasoning (R): The data inside a dictionary is stored as the key:value pairs enclosed...
Question 8Assertion (A): There is no difference between a list and a tuple in Python.Reasoning (R): The list elements are enclosed within square...
Question 9Assertion (A): Both max() and min() functions are implemented on lists as well as tuples in Python.Reasoning (R): The max() and min()...
Question 10Assertion (A): You can add an element in a dictionary using key:value pair.Reasoning (R): A new (key:value) pair is added only when the...
Question 1Assignment (=) operator is the Python operator responsible for assigning values to the variables.
Question 2Dynamic typing refers to declaring multiple values with different data types as and when required.
Question 3A comma (,) is used to separate a key-value pair in dictionary.
Question 4Partition() function will always return tuple of 3 elements.
Question 5The reserved words in Python are called keywords and these cannot be used as names or identifiers.
Question 6An operator is a symbol used to perform an action on some value.
Question 7Tuple(seq) function is used to convert a sequence data type into tuple.
Question 8The script files in Python have .py extension.
Question 9id() function is used to retrieve the address of a variable in memory.
Question 10Each object in Python has three key attributes—a type, a value and an id.
Question 11In Python, the non-zero value is treated as True and zero value is treated as False.
Question 12Keys of a dictionary must be unique.
Question 13In Bubble sort, the adjoining values in a sequence are compared and exchanged repeatedly until the entire array is sorted.
Question 14Logical operators are used to combine two or more relational/conditional expressions.
Question 15The len() function returns the length of a specified list.
Question 16None data type signifies the absence of value and doesn't display anything.
Question 1Which of the following is not considered a valid identifier in Python ?two2_mainhello_rsp12 hundred
Question 2What will be the output of the following code — print("100 + 200") ?300100200100 + 200200
Question 3Which amongst the following is a mutable data type in Python ?intstringtuplelist
Question 4Which of the following statements are not correct?(A) An element in a dictionary is a combination of key-value pair.(B) A tuple is a...
Question 5Which of the following statements converts a tuple into a list ?len(string)list(tuple)tup(list)dict(string)
Question 6The statement: bval = str1 > str2 shall return ............... as the output if two strings str1 and str2 contains "Delhi" and "New...
Question 7What will be the output generated by the following snippet?a = [5,10,15,20,25] k = 1 i = a [1] + 1 j = a [2] + 1 m = a [k + 1] print (i,...
Question 8The process of arranging the array elements in a specified order is termed as:IndexingSlicingSortingTraversing
Question 9Which of the following Python functions is used to iterate over a sequence of numbers by specifying a numeric end value within its...
Question 10What is the output of the following ?d = {0: 'a', 1: 'b', 2: 'c'} for i in d: print(i)1.0 1 2 2.a b c 3.0 a 1 b 2 c...
Question 11What is the output of the following ?x = 123 for i in x: print(i)1 2 3123ErrorInfinite loop
Question 12Which arithmetic operator(s) cannot be used with strings ?+*-All of these
Question 13What will be the output when the following code is executed?>>> strl = "helloworld" >>> strl[ : :...
Question 14What is the output of the following statement?print("xyyzxyzxzxyy".count('yy', 1))201Error
Question 15Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:[0, 1, 2, 3][0, 1, 2, 3, 4][0.0, 0.5, 1.0, 1.5][0.0, 0.5, 1.0, 1.5, 2.0]
Question 16Which is the correct form of declaration of dictionary?Day = {1: 'monday', 2: 'tuesday', 3: 'wednesday'}Day = (1; 'monday', 2; ' tuesday',...
Question 17Identify the valid declaration of L:L = [1, 23, 'hi', 6]listdictionaryarraytuple
Question 18Identify the valid declaration of L:L = {1: 'Mon', 2 : '23', 3: 'hello', 4: '60.5'}dictionarystringtuplelist
Question 19In which data type does input() function return value ?FloatIntStringBoolean
Question 20Which of the following is a valid relational operator in Python ?+**>and
Question 21Write the output of the following code:a = 10/2 b = 10//3 print(a, b)5 3.35.0 3.35.0 35 4
Question 22Which of the following is a valid variable name ?Student Name3Number%Name%Block_number
Question 1What are the advantages of Python programming language?
Question 2In how many different ways can you work in Python?
Question 3What are the advantages/disadvantages of working in interactive mode in Python?
Question 4Write Python statement for the following in interactive mode:To display sum of 3, 8.0, 6*12To print sum of 16, 5.0, 44.0
Question 5What are operators? Give examples of some unary and binary operators.
Question 6What is an expression and a statement?
Question 7What all components can a Python program contain?
Question 8What are variables? How are they important for a program?
Question 9(i)Write the output of the following:for i in '123': print("CPU", i)
Question 9(ii)Write the output of the following:for i in [100, 200, 300]: print(i)
Question 9(iii)Write the output of the following:for j in range(10, 6, -2): print(j*2)
Question 9(iv)Write the output of the following:for x in range(1, 6): for y in range(1, x+1): print (x, ' ', y)
Question 9(v)Write the output of the following:for x in range(10, 20): if (x == 15): break print(x)
Question 9(vi)Write the output of the following:for x in range(10, 20): if (x % 2 == 0): continue print(x)
Question 10Write the output of the following program on execution if x = 50:if x > 10: if x > 25: print("ok") if x > 60:...
Question 11What are the various ways of creating a list?
Question 12What are the similarities between strings and lists?
Question 13Why are lists called a mutable data type?
Question 14What is the difference between insert() and append() methods of a list?
Question 15Write a program to calculate the mean of a given list of numbers.Solutionnumbers = eval(input("Enter a list: ")) if len(numbers) == 0:...
Question 16Write a program to calculate the minimum element of a given list of numbers.Solutionl = eval(input("Enter a list: ")) m = min(l)...
Question 17Write a code to calculate and display total marks and percentage of a student from a given list storing the marks of a...
Question 18Write a program to multiply an element by 2 if it is an odd index for a given list containing both numbers and strings.Solutionmixed =...
Question 19Write a program to count the frequency of an element in a list.Solutionmy_list = eval(input("Enter the list: ")) c = int(input("Enter the...
Question 20Write 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,...
Question 21A list Num contains the following elements:3, 25, 13, 6, 35, 8, 14, 45 Write a program to swap the content with the next value divisible...
Question 22Write 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...
Question 23Write a program to input any values for two tuples. Print it, interchange it and then compare them.Solutiontuple1 = eval(input("Enter the...
Question 24Write a Python program to input 'n' classes and names of class teachers to store them in a dictionary and display the same. Also accept a...
Question 25Write a program to store student names and their percentage in a dictionary and delete a particular student name from the dictionary. Also...
Question 26Write a Python program to input names of 'n' customers and their details like items bought, cost and phone number, etc., store them in a...
Question 27Write a Python program to capitalize first and last letters of each word of a given string.Solutioninput_string = input("Enter the string:...
Question 28Write a Python program to remove duplicate characters of a given string.Solutioninput_string = input("Enter the string: ") unique_chars =...
Question 29Write a Python program to compute sum of digits of a given number.Solutionnumber = int(input("Enter a number: ")) sum_of_digits = 0 while...
Question 30Write a Python program to find the second most repeated word in a given string.Solutioninput_string = input("Enter the string: ") words =...
Question 31Write a Python program to change a given string to a new string where the first and last characters have been exchanged.Solutioninput_str...
Question 32Write a Python program to multiply all the items in a list.Solutionlst = eval(input("Enter the list: ")) result = 1 for item in lst:...
Question 33Write a Python program to get the smallest number from a list.Solutionnumbers = eval(input("Enter the list: ")) smallest = min(numbers)...
Question 34Write a Python program to append a list to the second list.Solutionlist1 = eval(input("Enter the first list: ")) list2 = eval(input("Enter...
Question 35Write 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...
Question 36Write a Python program to get unique values from a list.Solutioninput_list = eval(input("Enter the list: ")) unique_values = [] for item...
Question 37Write a Python program to convert a string to a list.Solutionstring = input("Enter the string: ") char_list = list(string) print("String...
Question 38Write a Python script to concatenate the following dictionaries to create a new one:d1 = {'A': 1, 'B': 2, 'C': 3} d2 = {'D': 4 }Output...
Question 39Write a Python script to check if a given key already exists in a dictionary.Solutionmy_dict = eval(input("Enter the dictionary: "))...
Question 40Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are square of...
Question 41Write a Python script to merge two Python dictionaries.Solutiondict1 = eval(input("Enter the first dictionary: ")) dict2 =...
Question 42Write a Python program to sort a dictionary by key.Solutiondef bubble_sort_keys(keys): n = len(keys) for i in range(n - 1):...
Question 43Write a Python program to combine two dictionaries adding values for common keys.d1 = {'a': 100, 'b': 200, 'c':300} d2 = {'a': 300, 'b':...
Question 44Write a Python program to find the three highest values in a dictionary.Solutionmy_dict = eval(input("Enter the dictionary: "))...
Question 45Write a Python program to sort a list alphabetically in a dictionary.Solutionmy_dict = eval(input("Enter the dictionary: ")) for key,...
Question 46Write a Python program to count number of items in a dictionary value that is a list.Solutionmy_dict = eval(input("Enter the dictionary:...
Question 47Consider the following unsorted list:105, 99, 10, 43, 62, 8.Write the passes of bubble sort for sorting the list in ascending order till...
Question 48What will be the status of the following list after the First, Second and Third pass of the insertion sort method used for arranging the...
Question 49(a)Evaluate the following expression:6 * 3 + 4 ** 2 // 5 - 8
Question 49(b)Evaluate the following expression:10 > 5 and 7 > 12 or not 18 > 3
Question 50What is type casting?
Question 51What are comments in Python? How is a comment different from indentation?
Question 1The two statements x = int(22.0/7) and x = int(22/7.0) yield the same results.
Question 2The statement: x + 1 = x is a valid statement.
Question 3List slice is a list in itself.
Question 4Relational operators return either True or False.
Question 5break, continue, pass are the three conditional statements.
Question 6The % (modulus) operator cannot be used with the float data type.
Question 7The range() function is used to specify the number of iterations to be performed in for loop.
Question 8Assignment operator can be used in place of equality operator in the test condition.
Question 9Comments in Python begin with a "$\text{\textdollar}$" symbol.
Question 10In print() function, if we use a concatenate operator (+) between two strings, both the strings are joined with a space in between them.
Question 11If we execute Python code using prompt ">>>" then we call it an interactive interpreter.
Question 12Lists are immutable while strings are mutable.
Question 13The keys of a dictionary must be of immutable types.
Question 14Lists and strings in Python support two-way indexing.
Question 15Tuples can be nested and can contain other compound objects like lists, dictionaries and other tuples.