Class 12 CS Chapter 1 Python Revision Tour Solutions Sumita Arora New Syllabus / Uncategorized / By Neha Back Exercise Part A 1. What are tokens in Python ? How many types of tokens are allowed in Python ? Exemplify your answer. ...click here for answer 2. How are keywords different from identifiers ? ...click here for answer 3. What are literals in Python ? How many types of literals are allowed in Python ? ...click here for answer 4. Can nongraphic characters be used and processed in Python ? How ? Give examples to support your answer. ...click here for answer 5. Out of the following, find those identifiers, which cannot be used for naming Variables or Functions in a Python program : ...click here for answer 6. How are floating constants represented in Python ? Give examples to support your answer. ...click here for answer 7. How are string-literals represented and implemented in Python ? ...click here for answer 8. What are operators ? What is their function ? Give examples of some unary and binary operators. ...click here for answer 9. What is an expression and a statement ? ...click here for answer 10. What all components can a Python program contain ? ...click here for answer 11. What are variables ? How are they important for a program ? ...click here for answer 12. Describe the concepts of block or suite and body. What is indentation and how is it related to block and body ? ...click here for answer 13. What are data types ? How are they important ? ...click here for answer 14. How many integer types are supported by Python ? Name them. ...click here for answer 15. What are immutable and mutable types ? List immutable and mutable types of Python. ...click here for answer 16. What is the difference between implicit type conversion and explicit type conversion ? ...click here for answer 18. What is entry controlled loop ? Which loop is entry controlled loop in Python ? ...click here for answer 19. Explain the use of the pass statement. Illustrate it with an example. ...click here for answer 20. Below are seven segments of code, each with a part coloured. Indicate the data type of each coloured part by choosing the correct type of data from the following type. ...click here for answer Back Exercise Part B 1. Fill 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 that is less than the limit. You can assume that all prices and the limit are positive numbers. When a price 0 is entered the program terminates and prints the largest price that is less than the limit. # Solution ...click here for answer 2. Predict the outputs of the following programs : ...click here for answer 3. Find and write the output of the following python code : ...click here for answer 4. How many times will the following for loop execute and what’s the output ? ...click here for answer 5. Is the loop in the code below infinite ? How do you know (for sure) before you run it ? ...click here for answer Back Exercise Part C 1. Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, zero, or greater than zero, respectively. ...click here for answer 2. Write a program that returns True if the input number is an even number, False otherwise. ...click here for answer 3. Write a Python program that calculates and prints the number of seconds in a year. ...click here for answer 4. Write a Python program that accepts two integers from the user and prints a message saying if first number is divisible by second number or if it is not. ...click here for answer 5. Write 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 Tuesday etp. Then the program should display the day on the day-number that has been input. # Code ...click here for answer 6. One foot equals 12 inches. Write a function that accepts a length written in feet as an argument and returns this length written in inches. Write a second function that asks the user for a number of feet and returns this value. Write a third function that accepts a number of inches and displays this to the screen. Use these three functions to write a program that asks the user for a number of feet and tells them the corresponding number of inches. # Code ...click here for answer 7. Write 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 nonnegative. If N is a negative number, then it’s the sum of the numbers from (2 * N) to N. The starting and ending points are included in the sum. # Code ...click here for answer 8. Write 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 the format , . ...click here for answer 9. Write a program that prints a table on two columns – table that helps converting miles into kilometres. ...click here for answer 10. Write another program printing a table with two columns that helps convert pounds in kilograms. ...click here for answer 11. Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between the two times. ...click here for answer