wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Code X Trade

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

How many times i value is checked in the following C program

#include <stdio.h>

int main()

{

int i = 0;

while (i < 3)

i++;

printf("In while loop\n");

}

a)

2

b)

3

c)

4

d)

1

2.

What will be output if you will compile and execute the following c code?

#include<stdio.h>

int main(){

int array[3]={5};

int i;

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

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

return 0;

}

a)

5 garbage garbage

b)

5 0 0

c)

5 null null

d)

compiler error

3.

What will be the output of the following C code?

#include <stdio.h>

void main(){

int a = 1, b = 1, c;

c = a++ + b;

printf("%d, %d", a, b);

}

a)

1,1

b)

2,1

c)

1,2

d)

2,2

4.

Predict the output for the following c code

#include<stdio.h>

void main(){

char s[]="abcd";   

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

    printf("\t%d",i);

}

}

a)

syntax error

b)

abcd

c)

0123

d)

0 1 2 3

5.

Predict the output for the following c code

#include <stdio.h>

void main(){

int result= 1 < 2 ? 2:1; 

printf("%d",result);

}

a)

1

b)

error

c)

True

d)

2

6.

What is the output of the following python code?

var1 = 1

var2 = 2'

var3 = "3"

print(var1 + var2 + var3)

a)

6

b)

33

c)

123

d)

Error

7.

What is the output of the following python code?

listOne = [20, 40, 60, 80]

listTwo = [20, 40, 60, 80]

 

print(listOne == listTwo)

print(listOne is listTwo)

a)

True True

b)

True False

c)

False True

d)

False False

8.

What is the output of the following python code?

var= "James Bond"

print(var[2::-1])

a)

mes

b)

aj

c)

maj

d)

dnoB se

9.

What is the output of the following python code?

var = "James" *2  * 3

print(var)

a)

JamesJamesJamesJamesJamesJames

b)

JamesJamesJames

c)

JamesJames

d)

error

10.

Find the output for the given  python program:

list1 = [[1, 2], [3, 4]]

list2 = list1

list2[0][0] = 0

print(list1)

a)

[1, 2, 3, 4]

b)

[0, 2, 3, 4]

c)

[[0, 2],[ 3, 4]]

d)

[[1, 2], [3, 4]]

11.

predict the next value

 1, 2, 3, 5, 7, 11, _

a)

14

b)

13

c)

9

d)

12

12.

If a = 1, b = 2, c = 3.......z = 26 what is the value of t+j+p?

a)

33

b)

51

c)

46

d)

52

13.

How many two digit numbers have their square ending with 8.

a)

13

b)

7

c)

0

d)

11

14.

Find the missing term 6, ?, 21, 33, 48

a)

14

b)

20

c)

12

d)

18

15.

Complete the sequence

A, e, i, m, q, u,,

a)

Y,c

b)

G,i

c)

B,f

d)

None