0% found this document useful (0 votes)
13 views

Assignment Solution

The document contains a 10 question multiple choice quiz on basic programming concepts in Python. It also includes two other questions - one asking to write a simple Python program based on pseudocode, and another asking to identify true/false statements about programming languages and their relationships. The quiz covers topics like variables, conditionals, operators, data types, and translating between binary and decimal.

Uploaded by

may
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Assignment Solution

The document contains a 10 question multiple choice quiz on basic programming concepts in Python. It also includes two other questions - one asking to write a simple Python program based on pseudocode, and another asking to identify true/false statements about programming languages and their relationships. The quiz covers topics like variables, conditionals, operators, data types, and translating between binary and decimal.

Uploaded by

may
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to Programming

Question I. (Total 10 marks)

Multiple Choice Questions


(i) What will be the output of the following program?
If 28:
Print(‘Hi’)
Else:
Print(‘Bye’)
a. Hi b. Bye c. None of the above d. The above snippet will not compile
Answer: a
(ii) What will be the output of the following program?
X=5
Y=5
print(X=Y)
a. 1 b. 1.0 c. 0.1 d. None of the above
Answer: d
(iii) What will be the output of the following statement?
print(2* 20 / 5 + 4 %2*3 - 1)
a. 7.0 b. 8 c. 9 d. 10
Answer: a
(iv) Which of the following is not a valid Python variable?
a. my_name1 b. myName1 c. 1myname d. _myname1
Answer: c
(v) What will be stored in num after the execution of the following code?
i=10
j=40
if i > j:
num = i
elif j>i:
num = j
else:
num = “equal”
print(“Num = ”,num)
a. 10 b. 20 c. 30 d. None of the above
Answer: d
(vi) What will be the output of the following program?
n = int(input(“Enter a three digit number\t:”))
if (n%10)==(n/100):
print(“Hi”)
else:
print(“Bye”)
# The three digit number entered by the user is 453
a. Hi b. Bye c. None of the above d. The code will not compile
Answer: b
(vii) What will be the output of the following program?
mark = 65
if mark >= 70:
print('Grade A')
elif mark >= 60:

Page 1 of 3
print('Grade B')
elif mark >= 50:
print('Grade C')
elif mark >= 40:
print('Grade D')
else:
print('Fail')
a. Grade A b. Grade B c. Grade C d. Grade D e. Fail
Answer: b
(viii) What will the binary value (11011) be in decimal?
a. 0, 1, 2, b. 1, 2, 3, c. 2, 3, 4, d. None of the Above
Answer: d
(ix) What will be the decimal value (93) be in binary?
a. 1, 2, 3, 4 b. 2, 4, 6, 8 c. 1, 3, 5, 7 d. None of the Above
Answer: d
(x) Which of the following Python logical expressions can determine whether z is less than both
x and y?
a. x & y > z b. (x > z) & (y > z) c. (y > z) & (x > z)
d. Both b and c e. All of the above
Answer: e

Question II. (Total 10 marks)


Write a program using Python to implement the following logic in the pseudocode.
Pseudocode:
BEGIN
READ mark
IF (mark>40) THEN
DISPLAY “Exam Cleared”
ELSE
DISPLAY “Failed”
END IF
END
Solution
Mark = int(input(“Enter a mark: “))
if (Mark > 40):
print(“Exam Cleared”)
else:
print(“Failed”)

Question III (Total 20 marks)

State True or False:


(i) Machine language is close to the programmer. (F)
(ii) Machine language is difficult to write. (T)
(iii) High level language is more close to the machine. (F)
(iv) Assembler translates high level language to machine language. (F)
(v) Machine languages are composed of 0’s and 1’s. (F)

Page 2 of 3
(vi) Assembly and machine languages are known as low level languages. (T)
(vii) Compilers occupy more memory than interpreters. (T)
(viii) Interpreter is faster than compiler. (F)
(ix) Python is an example of high level languages. (T)
(x) Python use both Interpreter and Compiler. (F)

***** End of Questions *****

Page 3 of 3

You might also like