Search Header Logo

JCITP92

Authored by jata code

Computers

1st Grade

JCITP92
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the use of functions in Python?

Functions are reusable pieces of programs

A function can take an unlimited number of arguments.

A Python function can return multiple values

All of the mentioned

Answer explanation

Functions are reusable pieces of programs. They allow you to give a name to a block of statements, allowing you to run that block using the specified name anywhere in your program, multiple times

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which one of the following keywords is used to define a function?

fun


define

def

function

Answer explanation

In Python, a function is defined using the def keyword followed by the name of the function and arguments. You can pass data, known as arguments, into a function. A function can return data as its result

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following Python code? def sayHello(): print('Hello World!') sayHello() sayHello()

Hello World! Hello World!

Hello World! + Hello World!

Hello Hello

sayHello sayHello

Answer explanation

Functions are defined using the def keyword. To call a function, we write the name of the function with (). Here, we are calling the function two times (sayHello()), which will print Hello World! two times

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? def cal(m,n): if m==n: print(m*3) else: print(n*3) cal(2, 4)

6

7

12

3

Answer explanation

Here, we passed 2 arguments - m and n, into the function named cal. We want to print 3 times of m if m is equal to n, otherwise it will print 3 times of n. Then we called the cal function with the values for m and n, i.e., 2, 4 . Since the if condition (m == n) is false , the output will be n*3, i.e., 4*3

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

def Fun(n) : print(n) What is "n" here?

Variable

Argument

Keyword

None of the above

Answer explanation

An argument is the value that is sent to the function when it is called. You can add as many arguments as you want, just separate them with a comma. Here, Fun function has one argument (n)

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?