Python Quiz on Functions, Built-in Functions & Function arguments

Functions are an integral part of any programming language as they promote code reuse and provide modularity to the code. We have plenty of built-in functions and we can create user functions as well.

Let us now check our knowledge of functions in Python with the quiz. All the best!

Summary

Functions are one of the major tools of any programmer. They help us to enhance code quality and promote code reusability. With the quiz, you might have understood your knowledge of functions and arguments as well. Any good programmer won’t move ahead until he clearly understands this topic.

Happy Learning!

3 Responses

  1. Subham Giri says:

    how q.10 become None of these please explain

  2. Subham Giri says:

    Explain the q.13 how it comes 1001 . Wrong ans how tehe correct ass will be 969. Option is not available.

  3. Ravi says:

    Variable Initialization:

    org = ‘ QuizOrbit ‘: Initializes a string variable org with the value ‘ QuizOrbit ‘.
    Function Definition (calcScore):

    def calcScore(org):: Defines a function named calcScore that takes a string parameter org.
    Variable Initialization (res):

    res = 0: Initializes an integer variable res with the value 0. This variable will be used to accumulate the sum of ASCII values.
    For Loop (for ele in org):

    for ele in org:: Iterates over each character (ele) in the string org.
    res += ord(ele): Adds the ASCII value of the current character ele to the variable res.
    Return Statement (return res):

    return res: Returns the final sum of ASCII values calculated in the calcScore function.
    Function Call (print(calcScore(org))):

    Calls the calcScore function with the argument org and prints the result.
    Explanation:
    The program calculates the sum of ASCII values of all characters in the string org.
    The ASCII value of a character is obtained using the ord() function.
    The for loop iterates over each character in the string, and the ASCII value of each character is added to the variable res.
    The final sum of ASCII values is returned by the calcScore function and printed.
    Output:
    For the given string ‘ QuizOrbit ‘, the ASCII values are calculated as follows:

    scss
    Copy code
    32 (space) + 81 + 117 + 105 + 122 + 79 + 114 + 98 + 105 + 116 + 32 (space)
    Summing these values: 32 + 81 + 117 + 105 + 122 + 79 + 114 + 98 + 105 + 116 + 32 = 1039

    So, the output of the program will be 1039, which is not present in option

Leave a Reply

Your email address will not be published. Required fields are marked *