0% found this document useful (0 votes)
105 views4 pages

Test 1 (+1 Portions Part-I) CS

Sachin took a test on 21/05/2023 that had 3 sections. Section 1 had 9 multiple choice questions on Python syntax and concepts. Section 2 had 6 short answer questions requiring code snippets. Section 3 had 3 coding questions requiring the user to write Python code. The document provided the questions, expected outputs, and in some cases, Sachin's answers.

Uploaded by

HArish R
Copyright
© © All Rights Reserved
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
0% found this document useful (0 votes)
105 views4 pages

Test 1 (+1 Portions Part-I) CS

Sachin took a test on 21/05/2023 that had 3 sections. Section 1 had 9 multiple choice questions on Python syntax and concepts. Section 2 had 6 short answer questions requiring code snippets. Section 3 had 3 coding questions requiring the user to write Python code. The document provided the questions, expected outputs, and in some cases, Sachin's answers.

Uploaded by

HArish R
Copyright
© © All Rights Reserved
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/ 4

NAME: SACHIN

DAY/DATE: SUNDAY 21/05/2023

TEST-1
Section-I Total:30
TIME:1hr
Choose the Correct Answer for the following: 9x1=9
1) Which of the following statements is correct syntactically?
a. print(“Anikha Venkat“ , sep == ‘@’ , end = ‘ ‘)
b. print(“Anikha Venkat“ , sep = ‘@’ , end = ‘ ‘)
c. Print(“Anikha Venkat“ , sep = ‘@’ , end = ‘ ‘)
d. print(“Anikha Venkat“ , sep = ‘@’ , end = ‘ ‘

ANSWER : B

2) What is the result after executing the following:


>>>print(20/4 *5+8-10)
a. 1 b. 23 c. 23.0 d. 24
ANSWER : B
3) Which of the following data types in Python supports
concatenation?
a) int b) float c) bool d) str
ANSWER : D
4) Which of the following data type in python is used to represent
any real number :
(a) int b) complex c ) float d ) bool
ANSWER : B
5) Find the invalid identifier from the following
a) Marks@12 b) string_12 c)_bonus d)First_Name
ANSWER : B
6) What will be the result of the following statements?
a) bool(int(“0“)) b) type(“hello“)
OUTPUT: FALSE str
7) Identify the output of the following python statements 1
import random
for n in range(2,5,2):
print(random.randrange(1,n,end=‘*‘)
a)1*3* b) 2*3* c) 1*3*4* d)1*4*
ANSWER:d
8) What will be the output for the following Python statement?
T=(10,20,[30,40,50],60,70)
T[2][1]=100
print(T)
a) (10,20,100,60,70) b) (10,20,[30,100,50],60,70)
c) (10,20,[100,40,50],60,70) d) None of these
ANSWER:D
9) What is the use of chr() function in python?
(a) returns the character for given ascii value
(b) returns the size of object
(c) returns the ascii value for given character
(d) convert the integer to string
ANSWER:D
Section-II
Answer the following questions: 6x2=12
1) Find the output:
p,q=8,[8]
r,s=3,4
p=r+s
q=[r,s]
print(p,q,sep='@')

OUTPUT:
7@[34]
2) Find the output:
p=5
q,r=10,5
p=r+q**2
print(p,end='#')
print(q)

OUTPUT:
105#
10

3) Identify the output of the following python code:


T=(9,18,27,36,45,54)
for i in T:
if i%6==0:
print(i,end=' ')

OUTPUT:
8 36 54
4) Kohit has written the following Python code. There are some
errors in it. Rewrite the correct code and underline the
corrections made.
x = input("Enter a number:")
if (abs(x)=x): UNWANTED BRACKET
print ("You entered a positive number")
else:
x=*-1 SYNTAXS ERROR( x*=-1 )
print "Number made positive:"x bracket necessary
ANSWER:
5) Can non-graphic characters be used and processed in Python?
How?
Answer:
Yes, we can use it with the help of backslash
for an example
print("my name is '\n' sachin")
output:
My name is
sachin

6) Differentiate Implicit type conversion and Explicit type


conversion with example

Section-III
Write the python coding for the following questions: 3x3=9
1) Accept an integer number from the user and Display the
greatest digit on that number. For example if the user enter a
number as 2973 then o/p 9
ANSWER:
x=eval(input(“enter number:”))
y=0
while x>0:
d=x%10
if d>y
y=d
x=x//10
print(“greatest digit”,y)

2) Accept two integer number from the user and Do the


interchange of values without third variable.

ANSWER
x=int(input(“enter the number :”))
y=int(input(“enter the number :”))

x=x+y
y=x-y
x=x-y

e.g
x,y=10,5

(x=10+5) #now x = 15
(y=15-5) #now y =10
(x=15-10 )#now x = 5

3) Write a program in python to input a number and display the


first Five alternative multiples. For Example
If the number given is 2
Then output should be 2 8 32 128 512

You might also like