Friday, 19 July 2019

Assessment Exam 3

Test 3:
Question paper


1.   Write a program to display avg of 3 subjects (maths, physics, comp)
(Note: Example program, marks can be any number)
>>> m=56
>>> p=76
>>> c=98
>>> total=m+p+c
>>> avg=total/3
>>> print(avg)
76.66666666666667
>>>

2.   Which one is valid in the following print statement:

(1) print(“Rajendra’s Laptop”)
(2.) print('rajendra's laptop')

Ans: (1)

3.   Write any example program by using membership operators (‘in’ or “not in”) in python. Hint: Input a=”Mera bharath mahan”


Ans1 : a=”Mera Bharath Mahan”
        print(“Mera” in a) 


Ans2: a=”Mera Bharath Mahan”
print(“Mera” not in a) 
        
4.   Write a python program swap the two numbers.  Input variables x=5,y=10
x = 5
y = 10
temp = x
x = y
y = temp
print('The value of x after swapping: {}'.x)
print('The value of y after swapping: {}'.y)


5. Following set of commands are executed in shell, what will be the output?
  1. >>>a="hello"
  2. >>>a[:2]
  3. >>>
a) he
b) lo
c) olleh
d) hello
View Answer
Answer: a
Explanation: We are printing only the 1st two bytes of string and hence the answer is “he”.
6. Write a program to find the word “learning” in the following string data type a

a=” We are learning Python” 

7. What is the output when the following statement is executed?
>>>"abcd"[2:]
a) a
b) ab
c) cd
d) dc
View Answer
Answer: c
Explanation: Slice operation is performed on a string.
8. What is the output when the following code is executed?

>>>print (r"\nhello")
View Answer
Answer: \nhello
9. What is the output when following statement is executed ?

>>>print('new' 'line')
View Answer
Answer: newline
10. Which of the following is not a complex number?
a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J
View Answer
Answer: c

Next Assessment: Assessment 3
Previous Assessment: Assessment Exam2
YouTube related videos

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...