Java Basics
Input/Output
Conditional Statements
Python
Loops in python
100

Name the basic primitive data types in java.
Atleast 5

int, float, double, boolean, char

100

Write the import statement that imports the scanner class to your program.

import java.util.Scanner;

100

What is the keyword you use to check for an alternate condition in case the 'if' condition fails?

else if

100

What is the function you use to take input from the user?

input()

100

while True :
   print("HI")

"Hi" is printed infinite times

200

What class do you import to take input from the user?

Scanner

200

What method do you write to take input for String data type?

next() or nextLine()

200

What is the logic you write to check if n is an even number?

n%2==0

200

What is the default data type of the value that input() takes?

String

200

What does the code do?
n = 6
c=0
while c<=n:
   print(c)
   c+=1

0 1 2 3 4 5 6

300

What are the different types of statements written to display output?

print, println, printf

300

If an input variable holds a value 3.62 then what is it's data type?

float or double

300

What is/are the keyword/s used for conditional statements other than if-else ladder?

switch and case

300

What is the output?
x = 82
y = 26
print("x+y")

x+y

300

What does this print in python?
for i in range(1,10):
   print(2*i)

prints first 10 multiples of 2

400

What is the return type of main method in java?

void

400

Is there anything that's missing?
Scanner s = new Scanner();

400

If you have to check if a variable s is holding the string "Happy Halloween", how do you write the condition?

if(s.equals("Happy Halloween")) or
if(s.equalsIgnoreCase("happy halloween"))

400

s = "Hello World!"
print(s[1:5])

ello

400

for i in range(1,5):
    for j in range(1,5):
         if i==j:
           print(i*j)

1 4 9 16 25

500

What words in the main method takes input from command line?

String[] args

500

printf() makes use of identifiers for variables. What will be the identifier for a variable of data type int?

%d

500

int a = 5;

int b = 10;

int c = 15;

if (a > 0) {

    if (b < 5) {

        System.out.println("First");

    } else if (c == 15) {

        System.out.println("Second");

    } else {

        System.out.println("Third");

    }

} else {

    System.out.println("Fourth");

}


Second


500

What does s[::-1] do to the string s?

Reverses the string

500

x = 3
y = 0
while x < 15:
    x = x * 2
    y = y + x
print(x,y)

24 42

M
e
n
u