Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MCQ for Coding Carnival

Total questions: 50

Worksheet time: 33mins

Name
Class
Date
1.

Lathika is curious about who developed the Python Programming Language. Can you help her find the right answer?

a)

Wick van Rossum

b)

Rasmus Lerdorf

c)

Guido van Rossum

d)

Niene Stom

2.

What will be the output of the following Python code?

>>>str1="helloworld"

>>>str1[::-1]

a)

dlrowolleh

b)

hello

c)

world

d)

helloworld

3.

output for the program

a)

prints all the even numbers between 1 and 20

b)

prints all the odd numbers between 1 and 21

c)

prints all the odd numbers between 1 and 20

d)

prints all the even numbers between 1 and 21

4.

The equivalent of the above for loop using the while syntax would be

a)

b)

c)

d)

5.

How many times will 1 be printed

a)

5

b)

3

c)

4

d)

7

6.

What is the order of precedence in Python?

i. Parenthesis

ii. Exponential

iii. Multiplication

iv. Division

v. Addition

vi. Subtraction

a)

1,2,3,4,5,6

b)

1,3,2,4,6,5

c)

6,5,4,3,2,1

d)

5,6,2,1,4,3

7.

(a)   is the example of comparison operator.

8.

what will be the output of the given equation:-

a=((2*5)(3*10))/5

print(a)

(a)  

9.

What is the output of the below code snippet?

a)

P 9

Q 10

R 2

S 6

b)

Tuple is immutable, so it will throw an error

c)

P 9

Q 10

R 2

S 6

T 6

d)

None of the above

10.

Which of the following functions can help us to find the version of python that we are currently working on?

a)

sys.version(1)

b)

sys.version(2)

c)

sys.version(3)

d)

sys.version(0)

11.

What does the following code fragment write to the monitor?

a)

under

b)

over

c)

under the limit

d)

over the limit

12.

Evaluate(to true or false) each of the following expressions:

(1) 14 <= 14

(2) 14 < 14

a)

true true

b)

true false

c)

false false

d)

false true

13.

The native language of the computer is ...............?

a)

high level language

b)

low level

language

c)

machine level

language

d)

both b & c

14.

The only fundamental language that dows not use any translator is called (a)   ?

15.

If originally x=2,y=0, and z=1, what is the value of x, y, and z after executing the following code?

if (x>y)

y=x;

else

z=x;

a)

x=2 y=2 z=1

b)

x=2 y=1 z=1

c)

x=0 y=2 z=0

d)

x=2 y=0 z=1

16.

What will be the output of the following C code?

a)

1

b)

2

c)

4

d)

6

17.

Directives are translated by the

(a)  

18.

What will be the output of the following code?

#include <stdio.h>

int main()

{

int *ptr, a = 10;

ptr = &a;

*ptr += 1;

printf("%d,%d/n", *ptr, a);

}

a)

10,10

b)

10,11

c)

11,10

d)

11,11

19.

Is an algorithm used to make the programmer do more work to solve the problem?

a)

yes

b)

no

20.

The visibilty modes are called as_____

a)

modifier

b)

accessibility

c)

access specifier

d)

polymorphism

21.

PREDICT THE OUTPUT:

int x = 60;

int y = 90;

if (y%x == 0 && y-x==30)

{

System.out.println("Hello World");

}

else

{

System.out.println("Error")

}

a)

error

b)

hello

c)

hello world

d)

Hello World

22.

Predict output for the given code snippet.

quote = 'No pain, no gain'

print(quote.islower())

a)

false

b)

true

23.

char c[] = "GATE2021";

char *p =c;

printf("%s", p + p[3] - p[1]) ;

What is the output of this program?

a)

GATE2021

b)

2021

c)

error

24.

struct {

short s [10]

union {

float y;

long z;

}u;

} t;

What is the output of this program?

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is

a)

22 bytes

b)

32 bytes

c)

16 bytes

d)

28 bytes

25.

What is the output of the program?

int main()

{

int a = 25%10;

printf("%d", a);

return 0;

}

a)

2.5

b)

5

26.

The C language is ........

a)

A regular language

b)

A context free language

c)

A context sensitive language

d)

Parsable fully only by a Turing machine

27.

What will be the output of the following code snippet?

1.

int ch = 2;

switch(ch) {

case 1: printf("1 ");

case 2: printf("2 ");

case 3: printf("3 ");

default: printf("None"); }

2.

What will be the output of the following code snippet?

int ch = 5 ;

switch(ch) {

case 1: printf("1 ");

case 2: printf("2 ");

case 3: printf("3 ");

default: printf("None"); }

a)

1. 2 3 None

2. Error

b)

1. 1 2 3 None

2. None

c)

1. 2 3 None

2. None

28.

How many edges will a tree consisting of N nodes have?

a)

N

b)

N+1

c)

N-1

d)

N-0

29.

What is the running time of the Huffman encoding algorithm?

a)

O(C)

b)

O(C log C)

c)

O( log C)

d)

O(N log C)

30.

In the given graph, what is the minimum cost to travel from vertex 1 to vertex 3?

a)

3

b)

10

c)

-4

d)

-3

31.

Which of the following can traverse the state space tree only in DFS manner?

a)

backtracking

b)

tracking

32.

What will be the output of the following C code?

a)

yes

b)

undefined behaviour

c)

compile time error

d)

default

33.

The continue statment cannot be used with (a)   .

34.

char s[ ]= "civil engineering association";

printf(s);

printf("%d",strlen(s));

a)

civil engineering association 27

b)

civil engineering association27

35.

(a)   is a piece of memory that can contain a data value.

36.

The term______ originally referred to any computation performed via a set of rulesapplied to numbers written in decimal form.

a)

algorithm

b)

pseudocode

c)

float

d)

coding

37.

What are not the Relational operators?

a)

<=

b)

>=

c)

+

d)

>

38.

The fastest data access is provided using __________

a)

DRAM

b)

SRAM

c)

Register

d)

Cache

39.

#include <stdio.h>

void main()

{

int i=10;

#type the loop code here

printf("%u ",i);

}

output should be infinite times

(a)  

40.

(a)   functions build the abstract data type ?

41.

Python supports _______

a . procedural programming

b . modular programming

c . object oriented programming

a)

All of these

b)

both b & c

c)

both a & b

d)

both a & c

42.

the tuple is also known as (a)   .

43.

When the Entity Relationship Model developed ?

a)

1967

b)

1976

c)

1980

d)

1970

44.

The Expansion for CRLF is

(a)  

45.

Which of the following is not scripting language ?

a)

Java

b)

PHP

c)

Perl

d)

HTML

46.

The OS Module which allows you to interface with the (a)   operating system.

47.

If (a)   :

print(x, "is a leap year")

48.

for letter in range(ord('A'), ord('F')):

print(chr(letter), end=" ")



(a)  

49.

output of the program

print(I Love KEC (a)   !!!)

50.

output of the code

s = "Welcome"

print(s.center(15, '$'))



(a)