Python Quiz

/5

Variables and Data Types

1 / 5

What will be the output of below code:

2 / 5

What will be the output of below code:


var1=1
var2=2
var3=”3”
print(var1+var2+var3)

3 / 5

What will be the output of below code:

4 / 5

What will be the output of below code:

5 / 5

What will be the output of below code:

def myfunc():
    x = 99
    return x
myfunc()
print(x)

Your score is

The average score is 39%

0%

Exit

/5

Strings

1 / 5

Which method is used to convert string “welcome to the beautiful world” to “Welcome To The Beautiful World”

2 / 5

What will be the output of below code:

str = “my name is jack”;

print (str.capitalize())

3 / 5

What will be the output of below code:

str1 = “my isname isisis Jameis isis bond”;

sub = ‘is’

print (str1.count(sub, 4)

4 / 5

What will be the output of below code:

str1 = “My salary is 7000”;

str2 = “7000”

print (str1.isdigit())

print (str2.isdigit())

5 / 5

What will be the output of below code:

print (“John” > “Jhon”)

print (“Emma” < “Emm”)

Your score is

The average score is 68%

0%

Exit

/3

Input and Output

1 / 3

What will be the output of below code:

2 / 3

What will be the output of below code:

print (sep=’-- ‘, Ben’, ‘25’, California’)

3 / 3

In Python3, which functions are used to accept input from the user and whatever you enter in the function converts it into which data types?

Your score is

The average score is 50%

0%

Exit

/5

Operators

1 / 5

What will be the output of below code:

2 / 5

What will be the output of below code:

3 / 5

What will be the output of below code:

4 / 5

What will be the output of below code:

5 / 5

What will be the output of below code:

str1 = ‘Welcome’

print(str1*2)

Your score is

The average score is 94%

0%

Exit

/5

Loops

1 / 5

What will be the output of below code:

for num in range (2, -5, -1):

   print (num, end = “,”)

2 / 5

What will be the output of below code:

for x in range (0.5, 5.5, 0.5):

  print(x)

3 / 5

Given the nested if-else below, what will be the value x when the code executed successfully

x = 0

a = 5

b = 5

if a > 0:

    if b < 0:

        x = x + 5

   elif a > 5:

        x = x + 4

   else:

        x = x + 3

else:

   x = x + 2

print(x)

4 / 5

What will be the output of below code:

for num in range (10, 14):

   for i in range (2, num):

       if num% i ==1:

          print(num)

          break

5 / 5

What will be the output of below code:

for i in range (10,15,1):

  print (i, end=’,’)

Your score is

The average score is 46%

0%

Exit

/5

Functions

1 / 5

What will be the output of below code:

def add (a, b):

   return a+5, b+5

 

result = add (3, 2)

print(result)

2 / 5

What will be the output of below code:

def calculate (num1, num2=4):

  res = num1*num2

  print(res)

calculate (5,6)

3 / 5

What will be the correct function declaration of func1() so that we can execute the following function call successfully

 

fun1(25,75, 55)

fun1(10, 20)

4 / 5

Please select the correct expression to reassign a global variable “x” to 20 inside a function fun1()?

x=50

def fun1():

   #your code to assign global x=20

fun1()

print(x) #it should print 20

5 / 5

What will be the output of below code:

def func1():

     x = 50

     Return x

func1()

print(x)

Your score is

The average score is 35%

0%

Exit