We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
MALAR PUBLIC SENIOR SECONDARY SCHOOL
(Affiliated to CBSE, New Delhi. Affiliation No: 1931085)
Teachers Colony, Paramathi(Po), Namakkal (Dt)
COMPUTER SCIENCE WORKSHEET 5
1. How will Python evaluate the following expression?
(20 + 30) * 40 2. How will the following expression be evaluated in Python? 15.0 / 4 + (8 + 3.0) 3. Give the output of the following when num1 = 4, num2 = 3, num3 = 2 a) num1 += num2 + num3 print (num1) b) num1 = num1 ** (num2 + num3) print (num1) c) num1 **= num2 + num3 print(num1) d) num1 = '5' + '5' print(num1) 4. Write a program to enter two integers and perform all arithmetic operations on them. 5. Write a program to swap two numbers without using a third variable. 6. What do you understand by term "immutable"? 7. What will be the output of the following ? 8. (a)87//5 (b)(87//5.0) == (87//5) (c) 87//5.0 (d) 17%5.0 9. Identify the data types of the following values given bellow – 3, 3j, 13.0, "12", ”14”, 2+0j, 19, [1,2,3], (3,4,5) 10. How will Python evaluate the following expression ? (i) 20 + 30 * 40 (ii) 20 - 30 + 40 11. What will be the output produced by following code fragment ? X=10 X=X+10 X=X-5 print (X) X, Y=X-2, 22 print (X, Y) 12. What will be the output produced by following code fragment? x, y=20, 60 y, x, y=x, y-10, x+10 print (x, y) 13. Which of the following is an invalid statement? a) abc = 1,000,000 b) a b c = 1000 2000 3000 c) a,b,c = 1000, 2000, 3000 d) a_b_c = 1,000,000 14. To convert the read value through input() into integer type, _____ () is used. 15. Which of the following is invalid variable name? a. Sum1 b. Num_1 c. Num 1 d. N1 16. From the following, find out which assignment statement will produce an error. State reason(s) too. (a) z = 0o98 (b) 56thnumber = 3300 (c) length = 450.17 (d) !Taylor = 'Instant' (e)x=100 17. Find out the error(s) in following code fragments: (i) temperature = 90 print temperature (ii) X=24 4=X 18. What are literals? How many types are there? 19. Write a program to input a number and print its square. 20. Which of the following identifier names are invalid and why? (i) Serial_no (ii) 1stroom. (iii) Hundred$ (iv) Total marks (v) True (vi) Total-marks