Quiz – Python

/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:

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

3 / 5

What will be the output of below code:


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

4 / 5

What will be the output of below code:

5 / 5

What will be the output of below code:

Your score is

The average score is 40%

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:

print (“John” > “Jhon”)

print (“Emma” < “Emm”)

3 / 5

What will be the output of below code:

str = “my name is jack”;

print (str.capitalize())

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:

str1 = “my isname isisis Jameis isis bond”;

sub = ‘is’

print (str1.count(sub, 4)

Your score is

The average score is 70%

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 51%

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:

a, b = 12, 5

if a + b:

    print(‘True’)

else:

    print (‘False’)

2 / 5

What will be the output of below code:

x=0

for i in range (10):

  for j in range (-1, -10, -1):

     x +=1

     print(x)

3 / 5

Select which is true for ‘for loop’

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

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)

Your score is

The average score is 49%

0%

Exit

/5

Functions

1 / 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)

2 / 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

3 / 5

What will be the output of below code:

def func1():

     x = 50

     Return x

func1()

print(x)

4 / 5

What will be the output of below code:

def add (a, b):

   return a+5, b+5

 

result = add (3, 2)

print(result)

5 / 5

What will be the output of below code:

salary = 8000

def printSalary ():

  salary=12000

  print (“Salary:”, salary)

printSalary ()

print (“Salary:”, salary)

Your score is

The average score is 37%

0%

Exit