105 solutions available
Question 1Assertion. Assigning a new value to an int variable creates a new variable internally.Reason. The int type is immutable data type of Python.
Question 2Assertion. """A Sample Python String""" is a valid Python String.Reason. Triple Quotation marks are not valid in Python.
Question 3Assertion. If and For are legal statements in Python.Reason. Python is case sensitive and its basic selection and looping statements are in...
Question 4Assertion. if and for are legal statements in Python.Reason. Python is case sensitive and its basic selection and looping statements are in...
Question 5Assertion. The break statement can be used with all selection and iteration statements.Reason. Using break with an if statement is of no...
Question 6Assertion. The break statement can be used with all selection and iteration statements.Reason. Using break with an if statement will give...
Question 1The smallest individual unit in a program is known as a token.
Question 2A token is also called a lexical unit.
Question 3A keyword is a word having special meaning and role as specified by programming language.
Question 4The data types whose values cannot be changed in place are called immutable types.
Question 5In a Python expression, when conversion of a value's data type is done automatically by the compiler without programmer's intervention, it...
Question 6The explicit conversion of an operand to a specific type is called type casting.
Question 7The pass statement is an empty statement in Python.
Question 8A break statement skips the rest of the loop and jumps over to the statement following the loop.
Question 9The continue statement skips the rest of the loop statements and causes the next iteration of the loop to take place.
Question 10Python's keywords cannot be used as variable name.
Question 1Which of the following is an invalid variable?my_day_22nd_dayDay_two_2
Question 2Find the invalid identifier from the following:namebreaksectionmark12
Question 3Which of the following is not a keyword?evalassertnonlocalpass
Question 4Which of the following cannot be a variable?_init_initon
Question 5Which of these is not a core data type?ListsDictionaryTuplesClass
Question 6How would you write xy in Python as an expression ?x^yx**yx^^ynone of these
Question 7What will be the value of the expression? 14 + 13 % 151427120
Question 8Evaluate the expression given below if A = 16 and B = 15. A % B // A0.001.01
Question 9What is the value of x? x = int(13.25 + 4/2)17141523
Question 10The expression 8/4/2 will evaluate equivalent to which of the following expressions:8/(4/2)(8/4)/2
Question 11Which among the following list of operators has the highest precedence? +, -, **, %, /, <<, >>, |<<, >>**I%
Question 12Which of the following expressions results in an error?float('12')int('12')float('12.5')int('12.5')
Question 13Which of the following statement prints the shown output below?...
Question 14Which value type does input() return ?BooleanStringIntFloat
Question 15Which two operators can be used on numeric values in Python?@%+#
Question 16Which of the following four code fragments will yield following output?Eina Mina Dika Select all of the function calls that result in...
Question 17Which of the following is valid arithmetic operator in Python ://?<and
Question 18For a given declaration in Python as s = "WELCOME", which of the following will be the correct output of print(s[1::2])?WELCOMEWLOEECM
Question 19Which of the following is an incorrect Logical operator in Python?notinorand
Question 20Which of the following is not a Tuple in Python?(1,2,3)("One","Two","Three")(10,)("One")
Question 1The expression int(x) implies that the variable x is converted to integer.
Question 2The value of the expressions 4/(3*(2 - 1)) and 4/3*(2 - 1) is the same.
Question 3The value of the expressions 4/(3*(4 - 2)) and 4/3*(4 - 2) is the same.
Question 4The expression 2**2**3 is evaluated as: (2**2)**3.
Question 5A string can be surrounded by three sets of single quotation marks or by three sets of double quotation marks.
Question 6Variables can be assigned only once.
Question 7In Python, a variable is a placeholder for data.
Question 8In Python, only if statement has else clause.
Question 9Python loops can also have else clause.
Question 10In a nested loop, a break statement terminates all the nested loops in one go.
Question 1What are tokens in Python? How many types of tokens are allowed in Python? Exemplify your answer.
Question 2How are keywords different from identifiers?
Question 3What are literals in Python? How many types of literals are allowed in Python?
Question 4State True or False : "Variable declaration is implicit in Python."
Question 5Out of the following, find those identifiers, which cannot be used for naming Variables or Functions in a Python...
Question 6Find the invalid identifier from the following :MyNameTrue2ndNameMy_Name
Question 7Which of the following is an invalid datatype in Python ?SetNoneIntegerReal
Question 8Identify the valid arithmetic operator in Python from the following:?<**and
Question 9How are floating constants represented in Python? Give examples to support your answer.
Question 10How are string-literals represented and implemented in Python?
Question 11What are operators ? What is their function? Give examples of some unary and binary operators.
Question 12Which of the following are valid operators in Python:***/like||is^betweeninAnswersThe valid operators are:** ⇒ Exponentiation operatoris ⇒...
Question 13What is an expression and a statement?
Question 14What all components can a Python program contain?
Question 15What are variables? How are they important for a program?
Question 16Consider the given expression: not True and False or TrueWhich of the following will be correct output if the given expression is...
Question 17Describe the concepts of block and body. What is indentation and how is it related to block and body?
Question 18(a)What are data types? How are they important?
Question 18(b)Write the names of any four data types available in Python.
Question 19How many integer types are supported by Python? Name them.
Question 20What are immutable and mutable types? List immutable and mutable types of Python.
Question 21What is the difference between implicit type conversion and explicit type conversion?
Question 22An immutable data type is one that cannot change after being created. Give three reasons to use immutable data.
Question 23What is entry controlled loop? Which loop is entry controlled loop in Python?
Question 24Explain the use of the pass statement. Illustrate it with an example.
Question 25Rewrite the adjacent code in python after removing all syntax error(s). Underline each correction done in the code.30 = To for K in...
Question 26Below are seven segments of code, each with a part coloured. Indicate the data type of each coloured part by choosing the correct type of...
Question 27Write the output of the following Python code:for i in range(2,7,2): print(i*'$')
Question 1Fill in the missing lines of code in the following code. The code reads in a limit amount and a list of prices and prints the largest price...
Question 2aPredict the output of the following code fragments:count = 0 while count < 10: print ("Hello") count += 1
Question 2bPredict the output of the following code fragments:x = 10 y = 0 while x > y: print (x, y) x = x - 1 y = y + 1
Question 2cPredict the output of the following code fragments:keepgoing = True x=100 while keepgoing : print...
Question 2dPredict the output of the following code fragments:x = 45 while x < 50 : print (x)
Question 2ePredict the output of the following code fragments:for x in [1,2,3,4,5]: print (x)
Question 2fPredict the output of the following code fragments:for p in range(1,10): print (p)
Question 2gPredict the output of the following code fragments:for z in range(-500, 500, 100): print (z)
Question 2hPredict the output of the following code fragments:x = 10 y = 5 for i in range(x-y * 2):...
Question 2iPredict the output of the following code fragments:c = 0 for x in range(10): for y in range(5): c += 1 print (c)
Question 2jPredict the output of the following code fragments:x = [1,2,3] counter = 0 while counter < len(x): print(x[counter] * '%') for...
Question 2kPredict the output of the following code fragments:for x in 'lamp': print(str.upper(x))
Question 2lPredict the output of the following code fragments:x = 'one' y = 'two' counter = 0 while counter...
Question 2mPredict the output of the following code fragments:x = "apple, pear, peach" y = x.split(", ") for z in y : print(z)
Question 2nPredict the output of the following code fragments:x ='apple, pear, peach, grapefruit' y = x.split(', ') for z in y: if z < 'm':...
Question 3Which of the following is the correct output for the execution of the following Python statement ?print(5 + 3 ** 2 / 2)328.09.532.0
Question 4(i)How many times will the following for loop execute and what's the output?for i in range(-1, 7, -2): for j in range (3):...
Question 4(ii)How many times will the following for loop execute and what's the output?for i in range(1,3,1): for j in range(i+1):...
Question 5Find and write the output of the following python code:for Name in ['Jay', 'Riya', 'Tanu', 'Anil'] : print (Name) if Name[0] == 'T'...
Question 6Is the loop in the code below infinite? How do you know (for sure) before you run it?m = 3 n = 5 while n < 10: m = n - 1 n = 2 *...
Question 1Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, zero, or greater...
Question 2Write a program that returns True if the input number is an even number, False otherwise.Solutionx = int(input("Enter a number: ")) if x %...
Question 3Write a Python program that calculates and prints the number of seconds in a year.Solutiondays = 365 hours = 24 mins = 60 secs = 60...
Question 4Write a Python program that accepts two integers from the user and prints a message saying if first number is divisible by second number or...
Question 5Write a program that asks the user the day number in a year in the range 2 to 365 and asks the first day of the year — Sunday or Monday or...
Question 6One foot equals 12 inches. Write a function that accepts a length written in feet as an argument and returns this length written in inches....
Question 7Write a program that reads an integer N from the keyboard computes and displays the sum of the numbers from N to (2 * N) if N is...
Question 8Write a program that reads a date as an integer in the format MMDDYYYY. The program will call a function that prints print out the date in...
Question 9Write a program that prints a table on two columns — table that helps converting miles into kilometers.Solutionprint('Miles | Kilometres')...
Question 10Write another program printing a table with two columns that helps convert pounds in kilograms.Solutionprint('Pounds | Kilograms')...
Question 11Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between the two times.A...