wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C-Py QUIZ | ROUND 1

Total questions: 20

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is not a characteristic of an algorithm?

a)

Effectiveness

b)

Accuracy

c)

Finiteness

d)

Ambiguity

2.

What will be the output of the following Python code?

a = 10

b = 20

print(a + b)

a)

20

b)

30

c)

10 + 20

d)

a + b

3.

What will be printed by the following Python code?

for i in range(5):

    print(i, end=' ')

a)

1 2 3 4 5

b)

0 1 2 3 4

c)

0 1 2 3

d)

1 2 3 4

4.

Which collection type is ordered, changeable, and allows duplicate members in Python?

a)

Set

b)

Dictionary

c)

List

d)

Tuple

5.

What will be the output of the following code?

fruits = ["apple", "banana", "cherry"]

fruits.append("orange")

print(fruits)

a)

["apple", "banana", "cherry", "orange"]

b)

["orange", "apple", "banana", "cherry"]

c)

["apple", "banana", "cherry"]

d)

 ["apple", "banana"]

6.

Which function can be used to read keyboard input in Python?

a)

input()

b)

print()

c)

int()

d)

eval()

7.

 What will be the output of the following Python code?

try:

  print(10/0)

except ZeroDivisionError:

  print("Cannot divide by zero")

a)

Cannot divide by zero

b)

10/0

c)

ZeroDivisionError

d)

None of the above

8.

Which of the following is not a core data type in Python?

a)

Lists

b)

Dictionary

c)

Class

d)

Tuple

9.

Which keyword is used to create a function in Python?

a)

function

b)

def

c)

fun

d)

define

10.

What will be the output of the following Python code?

def add(a, b):

    return a + b

print(add(3, 5))

a)

3 + 5

b)

8

c)

add(3,5)

d)

None

11.

Which of the following is not a valid variable name in C?

a)

_sum

b)

FLOAT

c)

$var

d)

average1

12.

What will be the output of the following C code?

int main() {

  int x = 5;

  int y = 10;

  if(x == y) {

    printf("Equal");

  }

  else {

    printf("Not Equal");

  }

  return 0;

}

a)

Equal

b)

Not Equal

c)

5

d)

10

13.

Which of the following is the correct syntax for a for loop in C?

a)

for i = 0; i < 10; i++

b)

for (i = 0; i < 10; i++)

c)

for i in range(10):

d)

for(int i = 0; i < 10; i--)

14.

What is the output of the following code?

int main() {

  int arr[] = {1, 2, 3, 4};

  int i;

  

  for(i=0; i<4; i++) {

    printf("%d ", arr[i]);

  }

  return 0;

}

a)

1234

b)

1 2 3 4

c)

0 1 2 3

d)

Garbage Values

15.

Which function can be used to dynamically allocate memory in C?

a)

malloc()

b)

memalloc()

c)

alloc()

d)

calloc()

16.

What is the index of the first element of an array in C?

a)

0

b)

1

c)

2

d)

Depends on the size of the array

17.

Which keyword is used to declare a function in C?

a)

function

b)

def

c)

func

d)

void

18.

What is the size of int data type in C?

a)

8 bits

b)

16 bits

c)

32 bits

d)

Depends on the system architecture

19.

What is the output of the following code snippet?

int x = 10;

int y = 20;

printf("%d %d", x, y);

a)

10 20

b)

20 10

c)

x y

d)

30

20.

Which of the following is a valid declaration of two dimensional array in C?

a)

 int arr[3][5];

b)

int arr(3,5);

c)

int arr[3,5];

d)

int arr[[3],[5]];