Test 1 (+1 Portions Part-I) CS
Test 1 (+1 Portions Part-I) CS
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
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
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
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)
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