C# - C Sharp: BCP201 - Quiz 1


Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên

(nhấn nút 'Result' để biết kết quả)

Q1: Which statement creates a variable x with value 10?
int x = 10
x := 10
x = 10
var x = 10

Q2: What is the type of x = 3.14?
int
float
str
bool

Q3: Which variable name is valid?
2name
first-name
first_name
class

Q4: Which function returns the data type of a variable?
data()
typeof()
type()
var()

Q5: What is the value of y after this code?
x = 5
y = x
print(y)
x
y
5
Error

Q6: Which function is used to get user input?
scan()
read()
input()
get()

Q7: What is the type of data returned by input()?
int
float
str
bool

Q8: Which code reads an integer?
x = input()
x = int(input())
x = str(input())
x = read()

Q9: Which code reads a floating-point number?
float(input())
int(input())
str(input())
bool(input())

Q10: What does input("Enter name: ") do?
Prints a name
Reads a name
Deletes a name
Converts to int

Q11: Which keyword starts a conditional statement?
for
while
if
def

Q12: Which keyword is used for another condition in an if statement?
elif
else if
elseif
next

Q13: Which operator means equal to?
=
:=
==
===

Q14: Which keyword executes when the if condition is false?
elif
else
for
while

Q15: Which comparison operator means greater than or equal to?
>
<
>=
<=

Q16: Which logical operator means AND?
or
and
not
xor

Q17: Which keyword creates a while loop?
loop
while
repeat
for

Q18: Which statement exits a loop immediately?
stop
end
break
return

Q19: Which statement skips the current iteration?
pass
skip
continue
next

Q20: What commonly causes an infinite loop?
Missing increment
break
continue
pass

Q21: Which loop checks its condition before each iteration?
for
while
foreach
repeat

Q22: Which value is often used to control a while loop?
Counter variable
Dictionary
Tuple
Function

Q23: Which function is commonly used with a for loop?
range()
loop()
count()
step()

Q24: How many times does range(5) iterate?
4
5
6
Infinite

Q25: Which range generates numbers 1 through 5?
range(5)
range(1,5)
range(1,6)
range(0,5)

Q26: What is the step value in range(1,10,2)?
1
2
9
10

Q27: Which loop is best for iterating through a list?
for
while True
do while
repeat until

Q28: Which keyword is used to iterate through a sequence?
through
in
of
inside

Q29: Which symbol is used for lists?
()
{}
[]
<>

Q30: Which method adds an element to a list?
add()
insert()
append()
push()

Q31: Which method removes the last element from a list?
pop()
delete()
erase()
remove()

Q32: What function returns the length of a list?
size()
count()
len()
length()

Q33: Which method sorts a list?
order()
sort()
arrange()
sortedlist()

Q34: What is the index of the first element in a list?
0
1
-1
Depends on length

Q35: Which symbol is used for tuples?
[]
()
{}
<>

Q36: Are tuples mutable?
Yes
No
Sometimes
Only integers

Q37: Which tuple contains one element?
(5)
(5,)
[5]
{5}

Q38: Which function returns tuple length?
size()
count()
len()
length()

Q39: Can tuples contain duplicate values?
Yes
No
Only numbers
Only strings

Q40: Which symbol is used for dictionaries?
[]
()
{}
<>

Q41: What is a dictionary made of?
Values only
Keys only
Key-value pairs
Numbers only

Q42: Which method returns all keys?
keys()
getkeys()
key()
items()

Q43: Which method safely retrieves a value?
value()
fetch()
get()
search()

Q44: What does items() return?
Keys
Values
Key-value pairs
Length

Q45: Which method returns all values?
values()
items()
keys()
get()

Q46: Which collection stores unique values?
list
tuple
set
string

Q47: Which method adds an element to a set?
append()
insert()
add()
push()

Q48: Can sets contain duplicate values?
Yes
No
Sometimes
Only strings

Q49: Which operation finds common elements?
union()
difference()
intersection()
update()

Q50: Which operation combines all unique elements?
intersection()
union()
difference()
remove()

Q51: What is a frozenset?
Ordered set
Mutable set
Immutable set
Empty set

Q52: Which function creates a frozenset?
frozen()
frozenset()
freeze()
set()

Q53: Can you add elements to a frozenset?
Yes
No
Sometimes
Only integers

Q54: Why use a frozenset?
Faster printing
Prevent modification
Store duplicates
Sort data

Q55: Which keyword defines a function?
function
define
func
def

Q56: Which keyword returns a value from a function?
send
output
return
yield

Q57: What is a parameter?
Function result
Variable in function definition
Loop variable
List element

Q58: What is an argument?
Value passed to a function
Function name
Return value
Dictionary key

Q59: Can a function return multiple values?
Yes
No
Only integers
Only strings

Q60: Which built-in function prints output to the screen?
write()
display()
print()
show()

Q61: What is the value of x after the following code?
x = 8
x += 5
8
13
40
Error

Q62: Which expression converts the string "25" into an integer?
str("25")
float("25")
int("25")
bool("25")

Q63: What is the output?
x = 9
if x % 2 == 0:
    print("Even")
else:
    print("Odd")
Even
Odd
9
Error

Q64: Which comparison returns True?
7 < 3
4 != 4
6 >= 6
5 == 2

Q65: What is printed?
score = 75
if score >= 80:
    print("A")
elif score >= 70:
    print("B")
else:
    print("C")
A
B
C
Nothing

Q66: Which logical operator reverses a Boolean value?
and
or
not
xor

Q67: What is the final value of n?
n = 1
while n < 16:
    n *= 2
8
16
15
32

Q68: What is the output?
for i in range(2):
    print(i, end=" ")
1 2
0 1
2 3
0 1 2

Q69: Which keyword does nothing but is syntactically valid?
skip
pass
ignore
empty

Q70: What is the output?
total = 0
for i in range(1,4):
    total += i
print(total)
3
6
10
4

Q71: Which statement creates a list containing three strings?
("A","B","C")
{"A","B","C"}
["A","B","C"]
<"A","B","C">

Q72: What is the result?
nums = [4,5,6]
nums.insert(1,9)
[4,5,6,9]
[9,4,5,6]
[4,9,5,6]
[4,5,9,6]

Q73: Which expression accesses the last element of a list?
a[0]
a[last]
a[-1]
a[end]

Q74: What is printed?
t = (3,6,9)
print(t[1])
3
6
9
Error

Q75: Which method counts how many times a value appears in a tuple?
find()
index()
count()
search()

Q76: Which expression accesses the value associated with key "age"?
d.age
d("age")
d["age"]
d->age

Q77: Which dictionary method removes all items?
erase()
delete()
clear()
remove()

Q78: Which set method removes an element without raising an error if it is missing?
discard()
delete()
erase()
popitem()

Q79: Which operation checks whether 10 belongs to a set s?
10 inside s
10 in s
s.has(10)
contains(s,10)

Q80: What is the output?
def cube(x):
    return x ** 3

print(cube(2))
6
8
9
12

Q81: What is the value of x after the following code?
x = 20
x //= 3
6.67
6
7
20

Q82: Which built-in function converts a value to a Boolean?
boolean()
bool()
logic()
binary()

Q83: What is the output?
x = -4
if x > 0:
    print("Positive")
else:
    print("Not Positive")
Positive
Not Positive
0
Error

Q84: Which comparison evaluates to False?
8 != 5
9 <= 9
7 > 10
4 == 4

Q85: What is printed?
age = 18
if age >= 18:
    print("Adult")
Adult
Child
18
Nothing

Q86: What is the output?
i = 3
while i > 0:
    i -= 1
print(i)
3
1
0
-1

Q87: What is printed?
for i in range(3, 0, -1):
    print(i, end=" ")
0 1 2
3 2 1
1 2 3
3 2 1 0

Q88: Which statement is commonly used to terminate a program based on a condition inside a loop?
continue
break
pass
next

Q89: What is the output?
s = 0
for i in range(2,6):
    s += i
print(s)
12
14
16
18

Q90: Which slice returns the first three elements of list a?
a[1:3]
a[:3]
a[3:]
a[-3:]

Q91: What is the result?
a = [1,2,3]
a.extend([4,5])
[1,2,3,[4,5]]
[1,2,3,4,5]
[[1,2,3],4,5]
Error

Q92: Which tuple unpacking statement is correct?
(x,y)=5,6
x,y=(5,6)
tuple(x,y)=5,6
unpack(x,y)

Q93: What is the output?
t = (10,20,30)
print(t[-2])
10
20
30
Error

Q94: Which method updates a dictionary with another dictionary?
merge()
update()
append()
extend()

Q95: Which expression checks whether key "id" exists in dictionary d?
"id" has d
contains(d,"id")
"id" in d
d.exist("id")

Q96: Which set method removes and returns an arbitrary element?
pop()
remove()
discard()
clear()

Q97: Which operator returns elements that are in either set?
&
-
|
^

Q98: What is the output?
def add(a, b=4):
    return a + b

print(add(3))
3
4
7
Error

Q99: Which function call correctly uses keyword arguments?
sum(a=3,b=5)
sum(=3,=5)
sum(3=a,5=b)
sum(a:3,b:5)

Q100: What is printed?
def square(x):
    return x*x

print(square(5))
10
20
25
5

Q101: What is the value of x after executing the code?
x = 5
x **= 2
10
25
7
32

Q102: Which expression converts 8 into a string?
text(8)
str(8)
string(8)
char(8)

Q103: What is the output?
x = 12
if x % 3 == 0:
    print("Yes")
else:
    print("No")
Yes
No
12
Error

Q104: Which comparison evaluates to True?
2 > 8
10 < 5
7 <= 7
9 != 9

Q105: What is printed?
n = 15
if n < 10:
    print("Small")
else:
    print("Large")
Small
Large
15
Nothing

Q106: What is the output?
count = 0
while count < 4:
    count += 1
print(count)
3
4
5
0

Q107: What is printed?
for i in range(1,8,3):
    print(i, end=" ")
1 4 7
1 4
1 4 7 10
0 3 6

Q108: What is the output?
for i in range(5):
    if i == 2:
        continue
    print(i, end=" ")
0 1 2 3 4
0 1 3 4
2 3 4
1 2 3 4

Q109: What is printed?
total = 1
for i in range(1,4):
    total *= i
print(total)
24
6
9
12

Q110: Which expression returns every second element of list a?
a[::2]
a[:2]
a[2:]
a[::-1]

Q111: What is the result?
a = [10,20,30]
a.remove(20)
[10,20]
[10,30]
[20,30]
Error

Q112: Which method returns the first index of a value in a tuple?
find()
search()
index()
locate()

Q113: What is the output?
t = ("red","green","blue")
print(len(t))
2
3
4
Error

Q114: Which method removes a key and returns its value from a dictionary?
pop()
remove()
delete()
discard()

Q115: What is the value of d['b']?
d = {"a":1,"b":2}
1
2
"b"
Error

Q116: Which operator finds elements that exist in the first set but not the second?
|
&
-
^

Q117: Which operator returns elements that belong to one set but not both?
&
|
^
-

Q118: What is printed?
def multiply(a, b):
    return a * b

print(multiply(4, 5))
9
20
45
54

Q119: What is the output?
def greet(name="Tom"):
    return "Hi " + name

print(greet())
Hi
Tom
Hi Tom
Error

Q120: Which function call correctly passes two positional arguments?
calc(x=3, y=4)
calc(3, 4)
calc(,3,4)
calc(3=4)

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)

(Ghi chú: Phần câu hỏi Qi có màu Green thể hiện đáp án đúng)
» Tiếp: DBI202 - PT2
« Trước: Practical 12: Books Management System
Khóa học qua video:
Lập trình Python All Lập trình C# All SQL Server All Lập trình C All Java PHP HTML5-CSS3-JavaScript
Đăng ký Hội viên
Tất cả các video dành cho hội viên
Copied !!!