Python Class Room Diary – Be easy in My Python class



KENDRIYA VIDYALAY, BARKUHI WCLMONTHLY TEST : APRIL 2019CLASS- XIISUBJECT:- COMPUTER SCIENCE (083)TIME: 1.30 HRMM: 50---------------------------------------------------------------------------------------------------------------------General Instructions: All questions are compulsory. Write question number properly.Q 1:- (a) Which of the following can be used as valid variable identifier(s) in Python ? 2(i) 4thSum(ii) Total(iii) Number#(iv) _Data(b ) Name the function/method required to:-1(i) check if a string contains only alphabets (ii) give the total length of the list(c ) What is None literal in Python?1(d) What are python comments? Which character is used to determine the beginning of a python comment?1(e) Why can’t lists be used as keys?1Q 2:- (a) Rewrite the following code in python after removing all syntax error(s). Underlineeach correction done in the code.2Val = int(rawinput("Value:"))Adder = 0for C in range(1,Val,3)Adder+=Cif C%2=0:Print C*10Else:(print C*)print (Adder) (b) Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code. 2STRING=""WELCOMENOTE""for S in range[0,8]:print STRING(S)print (S+STRING)Q 3:- (a ) Find and write the output of the following python code:3Data = ["P",20,"R",10,"S",30]Times = 0Alpha = ""Add = 0for C in range(1,6,2):Times= Times + CAlpha= Alpha + Data[C-1]+"$"Add = Add + Data[C]print (Times,Add,Alpha) (b ) Find and write the output of the following Python code:3TXT = ["20","50","30","40"]CNT = 3TOTAL = 0for C in (7,5,4,6): T = TXT[CNT] TOTAL = float(T)+C print (TOTAL) CNT-=1Page-1Q 4:(a) What possible outputs(s) are expected to be displayed on screen at the time of execution of the program from the following code? Also specify the maximum values that can be assigned to each of the variables BEGIN and LAST.2import randomPOINTS=[20,40,10,30,15];POINTS=[30,50,20,40,45];BEGIN=random.randint(1,3)LAST=random.randint(2,4)for C in range(BEGIN,LAST+1):print (POINTS[C],"#",)(i) 20#50#30# (ii) 20#40#45#(iii) 50#20#40# (iv) 30#50#20#(b) What are the possible outcome(s) executed from the following code ? Also specify the maximum and minimum values that can be assigned to the variable NUM. 2import randomNAV = ["LEFT","FRONT","RIGHT","BACK"];NUM = random.randint(1,3)NAVG = " "for I in range (NUM,1,-1):NAVG = NAVG+NAV[I]print (NAVG)(i) BACKRIGHT (ii) BACKRIGHTFRONT(iii) BACK (iv) LEFTFRONTRIGHTQ 5:- Consider the following randomly ordered numbers stored in a list3+Note: Show the status of all the elements after each pass very clearly underliningthe changes.Q 6(a) Write definition of a method ZeroEnding(SCORES) to add all those values in the list of SCORES, which are ending with zero (0) and display the sum.2For example,If the SCORES contain [200,456,300,100,234,678]The sum should be displayed as 600 (b) Write definition of a Method AFIND(CITIES) to display all the city names from a list of CITIES, which are starting with alphabet A.2For example:If the list CITIES contains["AHMEDABAD","CHENNAI","NEW DELHI","AMRITSAR","AGRA"]The following should get displayedAHEMDABADAMRITSARAGRAQ 7: (a) Write a method to find and display the python the prime numbers between 2 to N. Pass N as an argument. 3(b) Write definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.3Q 8:- (a) Write a python script to count the number of keys. (Use any of the dictionary methods to count the key value pairs)2(b) Write a python code to count the frequency of even numbers in a list and store the frequency in a dictionary. 3Q 9: (a) What do you understand by scope of variables?2(b) Define argument and various types of arguments available in Python programming.3Q 10: (a) Write a Python function for use of arithmetic operation using multiple return statement.3(b) Write a Python program for GCD and LCM of two integer number using the function.4------------------------------------------------------------------XII(CS)--------------------------------------------------------------------Page-2 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download