0% found this document useful (0 votes)
25 views15 pages

Apf B23fa1152

This document contains 30 multiple choice questions about Python programming concepts like conditional statements, functions, operators, strings and lists. The questions test understanding of code snippets and predicting output. The correct answers are also given.

Uploaded by

bakuna0717
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)
25 views15 pages

Apf B23fa1152

This document contains 30 multiple choice questions about Python programming concepts like conditional statements, functions, operators, strings and lists. The questions test understanding of code snippets and predicting output. The correct answers are also given.

Uploaded by

bakuna0717
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/ 15

2. Дараах нөхцөл шалгах кодын үр дүн ямар гарах вэ?

X=0
a=0
b = -5
if a > 0:
if b < 0:
x=X+5
elif a > 5:
x=4
else:
x=X+3
else:
X=X+2
print(x)
a.2
b.3
c.4
d.5
X=0
a = 6 # Modified: Changed a to be greater than 5
b = -5

if a > 0:
if b < 0:
x=X+5
elif a > 5:
x = 4 # Corrected: Assigning x = 4
else:
x=X+3
else:
X=X+2

print(x)
A) 3
B) 4
C) 5
D) 7
X=0
a = -3 # Modified: Changed a to be less than 0
b = -5

if a > 0:
if b < 0:
x=X+5
elif a > 5:
x = 4 # Corrected: Assigning x = 4
else:
x=X+3
else:
X=X+2

print(x)
A) 1
B) 2
C) 3
D) 4

3. Дараах үйлдлийн үр дүн ямар гарах вэ?

a = [10, 20]
b = a.copy()
b += [3e, 40]
print(a)
print(b)
A) [10, 20] [10, 20]
B) SyntaxError
C) [10, 20] [10, 20, 3e, 40]
D) [10, 20, 3e, 40] [10, 20, 3e, 40]

a = [10, 20]
b = a.copy()
b += [30, 40]
print(a)
print(b)
A) [10, 20] [10, 20, 30, 40]
B) [10, 20, 30, 40] [10, 20, 30, 40]
C) [10, 20] [10, 20]
D) [10, 20] [10, 20, 30, 30]

a = [10, 20]
b=a
b += [30, 40]
print(a)
print(b)
A) [10, 20] [10, 20, 30, 40]
B) [10, 20, 30, 40] [10, 20, 30, 40]
C) [10, 20] [10, 20]
D) [10, 20] [10, 20, 30, 40]

6. Дараах нөхцөл шалгах кодын үр дүн ямар гарах вэ?


X=5
a=5
b = -5
if a > 0:
if b < 0:
X=X+5
elif a > 5:
X=X+4
else:
X=X+3
else:
X=X+2
print(X)
A) 7
B) 9
C) 10
D) 12

X=5
a = -3 # Modified: Changed a to be less than 0
b = -5

if a > 0:
if b < 0:
X=X+5
elif a > 5:
X=X+4
else:
X=X+3
else:
X=X+2

print(X)
A) 6
B) 7
C) 8
D) 9

X=5
a = 3 # Modified: Changed a to be less than 5 but greater than 0
b = -5

if a > 0:
if b < 0:
X=X+5
elif a > 5:
X=X+4
else:
X=X+3
else:
X=X+2

print(X)
A) 7
B) 8
C) 9
D) 10
7. Дараах нөхцөл шалгах кодын үр дүн ямар гарах вэ?
print(2 ** 2 ** 3)
A) 64
B) 128
C) 256
D) 512

print(3 ** 2 ** 4)
A) 81
B) 729
C) 6561
D) 59049

print(4 ** 2 ** 3)
A) 256
B) 4096
C) 16384
D) 65536

10. Дараах нөхцөл шалгах кодын үр дүн ямар гарах вэ?

a, b = 0, 5
if a + b:
print("True")
else:
print(False)
a. True
b. False
a, b = -1, 1
if a + b:
print("True")
else:
print(False)
a. True
b. False
a, b = 0, 0
if a + b:
print("True")
else:
print(False)
a. True
b. False
11.
print('Alice', 20, 'Texas', sep='***',)
A) 'Alice', 20, 'Texas'
B) Alice***20***Texas
C) Alice, 20, Texas
D) Alice--20—Texas

print('John', 30, 'New York', sep=':')


A) John:30:New York
B) 'John', 30, 'New York'
C) John--30--New York
D) John, 30, New York

print('Emma', 28, 'Florida', sep='-')


A) Emma-28-Florida
B) 'Emma', 28, 'Florida'
C) Emma--28--Florida
D) Emma, 28, Florida
12.
x = 25 % 5 * (2 + 4) * 5 + 4
A) 14
B) 24
C) 34
D) 44

x = 15 % 2 * (6 + 3) * 2 + 3
A) 5
B) 11
C) 17
D) 23

x = 20 % 3 * (4 + 2) * 3 + 1
A) 7
B) 13
C) 19
D) 25

13.
import math
print(math.floor(17.5))
print(math.ceil(17.5))
A. 17 17
B. 18 18
C. 17 18
D. 16 17
import math
print(math.floor(29.5))
print(math.ceil(29.5))
A. 28 29
B. 29 30
C. 30 30
D. 28 30
import math
print(math.floor(109.5))
print(math.ceil(109.5))
A. 109 110
B. 108 108
C. 109 109
D. 110 111
14.
print(20 - 9 % 4)
A) 15
B) 16
C) 18
D) 19

Print(25 - 7 % 5)
A) 20
B) 21
C) 22
D) 23

Print(15 - 8 % 3)
A) 13
B) 11
C) 12
D) 15
15.
X=8
y = 60
if (X ** 2 > 64 and y < 100):
print(X ** 2, y * 10)
else:
print(X, y)
A) 64 600
B) 64 500
C) 8 60
D) 8 600

X = 12
y = 40
if (X ** 2 > 144 and y < 100):
print(X ** 2, y * 10)
else:
print(X, y)
A) 144 400
B) 144 500
C) 12 40
D) 12 400

X=6
y = 70
if (X ** 2 > 36 and y < 100):
print(X ** 2, y * 10)
else:
print(X, y)
A) 36 700
B) 36 600
C) 6 70
D) 6 600
17.
x=8
y=3
print(x**y//y)
print(x//y**y)
A) 32, 2
B) 64, 1
C) 512, 1
D) 512, 2

x=5
y=4
print(x**y//y)
print(x//y**y)
A) 625, 0
B) 625, 0.3125
C) 625, 1
D) 625, 0

x=9
y=2
print(x**y//y)
print(x//y**y)
A) 81, 1
B) 81, 4.5
C) 81, 2
D) 81, 4
21.
X=0
a=5
b=0
if a > 0:
if b < 0:
X=X+5
elif a == 5:
X=X+4
else:
X=X+3
else:
X=X+2
print(X)
A) 0
B) 2
C) 4
D) 5

X=0
a=4
b=4
if a > 0:
if b < 0:
X=X+5
elif a == 4:
X=X+4
else:
X=X+3
else:
X=X+2
print(X)
A) 2
B) 4
C) 5
D) 6
X=0
a = -1
b=5
if a > 0:
if b < 0:
X=X+5
elif a == -1:
X=X+4
else:
X=X+3
else:
X=X+2
print(X)
A) 0
B) 2
C) 4
D) 5

24-25 дугаар бодлогууд ягаад error зааж байгааг олдоггүйээ багшаа


27.
string = "Python"
print(string[2:-2])
A) "tho"
B) "yth"
C) "th"
D) "thon"

string = "HelloWorld"
print(string[1:6])

A) "Hello"
B) "lloWo"
C) "elloW"
D) "elloWo"

string = "DataScience"
print(string[4:8])
A) "Sien"
B) "Sci"
C) "Scie"
D) "Scie"
29.
import math
print(math.floor(208.5))
print(math.ceil(208.5))
A. 208 209
B. 208 208
C. 209 209
D. 207 210

import math
print(math.floor(69.5))
print(math.ceil(69.5))
a. 69 69
b. 68 69
c. 67 68
d. 69 70

import math
print(math.floor(247.5))
print(math.ceil(247.5))

a. 247 247
b. 248 248
c. 247 248
d. 248 249
30.
import math
print(math.floor(123.5))
print(math.ceil(123.5))
a. Error
b. 122 123
c. 123 124
d. 122 122

import math
print(math.floor(17.5))
print(math.ceil(17.5))
a. 16 17
b. 17 17
c. 17 18
d. 18 19

import math
print(math.floor(99.5))
print(math.ceil(99.5))
a. 99 99
b. 99 100
c. 100 100
d. 98 101

You might also like