Code Execution Championship-round 1 -python

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Catherine Halcomb
C
Catherine Halcomb
Community Contributor
Quizzes Created: 1428 | Total Attempts: 5,897,934
Questions: 42 | Attempts: 557

SettingsSettingsSettings
Programming Quizzes & Trivia

Pls Note:
1) There are 20 questions in a quiz.
2) Time duration is 15 minutes.
3) Only one attempt is allowed.
4) Candidate can navigate questions and review answers before final submission
5) Compulsory to fill all the mentioned details.
6) Kindly provide the correct details.


Questions and Answers
  • 1. 

    Which of the following is correct about Python?

    • A.

      Python is a high-level, interpreted, interactive and object-oriented scripting language

    • B.

      Python is designed to be highly readable.

    • C.

      It uses English keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    Python is a versatile programming language that possesses several characteristics. It is a high-level language, meaning it provides abstractions that make it easier to write and understand code. It is also interpreted, allowing for immediate execution of code without the need for compilation. Python is interactive, allowing users to experiment and test code in real-time. Additionally, it is object-oriented, which means it organizes data and functions into objects for more efficient programming. Python is designed to prioritize readability, using English keywords instead of punctuation and having fewer syntactical constructions compared to other languages. Therefore, all of the given statements are correct about Python.

    Rate this question:

  • 2. 

    Which of the following function convert a String to an object in python?

    • A.

      Repr(x)

    • B.

      Eval(str)

    • C.

      Tuple(s)

    • D.

      List(s)

    Correct Answer
    B. Eval(str)
    Explanation
    The eval() function in Python can be used to convert a string into an object. It takes a string as input and evaluates it as a Python expression, returning the resulting object. This can be useful when working with dynamically generated code or when needing to convert a string representation of an object back into its original form. The repr() function returns a string representation of an object, while the tuple() and list() functions convert a sequence into a tuple and list respectively.

    Rate this question:

  • 3. 

    Which of the following operator in python evaluates to true if it does not finds a variable in the specified sequence and false otherwise?

    • A.

      **

    • B.

      //

    • C.

      Is

    • D.

      Not in

    Correct Answer
    D. Not in
    Explanation
    The "not in" operator in Python evaluates to true if it does not find a variable in the specified sequence and false otherwise. It is used to check if a value does not exist in a given sequence, such as a list or a string. If the value is not found in the sequence, the operator returns true. Otherwise, it returns false.

    Rate this question:

  • 4. 

    What is the following function returns the lowest index in list that obj appears?

    • A.

      List.index(obj)

    • B.

      List.insert(index, obj)

    • C.

      List.pop(obj=list[-1])

    • D.

      List.remove(obj)

    Correct Answer
    A. List.index(obj)
    Explanation
    The correct answer is "list.index(obj)". This function returns the lowest index in the list where the specified object "obj" appears. It searches for the first occurrence of the object and returns its index. If the object is not found in the list, it raises a ValueError.

    Rate this question:

  • 5. 

    What does the following code do?→def a(b, c, d): pass

    • A.

      Defines a list and initializes it

    • B.

      Defines a function, which does nothing

    • C.

      Defines a function, which passes its parameters through

    • D.

      Defines an empty class

    Correct Answer
    B. Defines a function, which does nothing
    Explanation
    The given code defines a function named "a" with three parameters: b, c, and d. However, the function body is empty as it only contains the "pass" statement. This means that the function does nothing and serves as a placeholder or a stub that can be filled with actual code later on.

    Rate this question:

  • 6. 

    Which of these in not a core datatype?

    • A.

      Lists

    • B.

      Dictionary

    • C.

      Tuples

    • D.

      Class

    Correct Answer
    D. Class
    Explanation
    The question asks for a core datatype, and the options provided are Lists, Dictionary, Tuples, and Class. Lists, Dictionary, and Tuples are all core datatypes in Python, but Class is not considered a core datatype. In Python, a class is a blueprint for creating objects, and it is used for creating user-defined objects with their own methods and attributes. Therefore, the correct answer is Class.

    Rate this question:

  • 7. 

    What is the return value of trunc() ?

    • A.

      Int

    • B.

      Bool

    • C.

      Float

    • D.

      None

    Correct Answer
    A. Int
    Explanation
    The return value of the trunc() function is an integer. This function is used to remove the decimal part of a number and return the integer value. Therefore, the correct answer is int.

    Rate this question:

  • 8. 

    Given a function that does not return any value, what value is shown when executed at the shell?

    • A.

      Int

    • B.

      Bool

    • C.

      Void

    • D.

      None

    Correct Answer
    D. None
    Explanation
    When a function does not return any value, it means that it has a return type of void. In programming, void is used to indicate that a function does not return any value. Therefore, when this function is executed at the shell, the value shown would be None.

    Rate this question:

  • 9. 

    Which of these is not a core data type?

    • A.

      Lists

    • B.

      Dictionary

    • C.

      Tuples

    • D.

      Class

    Correct Answer
    D. Class
    Explanation
    The correct answer is Class. In Python, lists, dictionaries, and tuples are all considered core data types because they are built-in and commonly used to store and manipulate data. However, a class is not a core data type but rather a blueprint for creating objects. Classes are used to define the structure and behavior of objects, allowing for code reusability and organization.

    Rate this question:

  • 10. 

    Which of the following is correct about Python?

    • A.

      It supports automatic garbage collection

    • B.

      It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java

    • C.

      Both of the above

    • D.

      None of the above.

    Correct Answer
    B. It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java
    Explanation
    Python can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java. This means that Python can interact and communicate with code written in these languages and technologies. This allows for seamless integration and collaboration between different programming languages and platforms, making Python a versatile and flexible language for various applications.

    Rate this question:

  • 11. 

    Which of the following is correct about tuples in python?

    • A.

      A tuple is another sequence data type that is similar to the list

    • B.

      A tuple consists of a number of values separated by commas.

    • C.

      Unlike lists, however, tuples are enclosed within parentheses

    • D.

      All of the above.

    Correct Answer
    B. A tuple consists of a number of values separated by commas.
    Explanation
    Tuples in Python are similar to lists as they are both sequence data types. However, tuples are enclosed within parentheses and consist of a number of values separated by commas. Therefore, the correct statement about tuples in Python is that "A tuple consists of a number of values separated by commas."

    Rate this question:

  • 12. 

    Which of the following functions is a built-in function in python?

    • A.

      Seed()

    • B.

      Sqrt()

    • C.

      Factorial()

    • D.

      Print()

    Correct Answer
    D. Print()
    Explanation
    The function "print()" is a built-in function in Python. It is used to display output on the console or terminal. The print() function takes one or more arguments and prints them as text. It is commonly used for debugging purposes and to display information to the user during program execution.

    Rate this question:

  • 13. 

    How many keyword arguments can be passed to a function in a single function call?

    • A.

      Zero

    • B.

      One

    • C.

      Zero or more

    • D.

      One or more

    Correct Answer
    C. Zero or more
    Explanation
    In Python, keyword arguments can be passed to a function in a single function call. The number of keyword arguments can be zero or more, meaning that it is not mandatory to pass any keyword arguments, but if needed, multiple keyword arguments can be provided. This allows for flexibility and customization when calling a function, as specific arguments can be passed by their names, rather than relying solely on their position in the function call.

    Rate this question:

  • 14. 

    Given a function that does not return any value, What value is thrown by default when executed in shell

    • A.

      Int

    • B.

      Bool

    • C.

      Void

    • D.

      None

    Correct Answer
    D. None
    Explanation
    When a function does not return any value, it is said to have a return type of "void". In programming languages like C or C++, when a function with a void return type is executed, it does not throw any value or result. Therefore, the default value thrown by such a function when executed in a shell is "None".

    Rate this question:

  • 15. 

    In order to store values in terms of key and value we use what core datatype

    • A.

      List

    • B.

      Tuple

    • C.

      Class

    • D.

      Dictionary

    Correct Answer
    D. Dictionary
    Explanation
    To store values in terms of key and value, we use the core datatype called a dictionary. A dictionary is a collection of key-value pairs, where each key is unique and associated with a value. It allows efficient retrieval of values based on their corresponding keys. Unlike lists or tuples, which store values in a sequential manner, a dictionary provides a way to organize and access data based on meaningful keys. Therefore, a dictionary is the appropriate core datatype for storing values in key-value pairs.

    Rate this question:

  • 16. 

    What is max(3, 5, 1, 7, 4)?

    • A.

      1

    • B.

      3

    • C.

      5

    • D.

      7

    Correct Answer
    D. 7
    Explanation
    The correct answer is 7 because the max() function is used to find the highest value among the given numbers. In this case, the highest value among 3, 5, 1, 7, and 4 is 7.

    Rate this question:

  • 17. 

    What is round(3.52)?

    • A.

      3.5

    • B.

      3

    • C.

      5

    • D.

      4

    Correct Answer
    D. 4
    Explanation
    The round() function is used to round a given number to the nearest whole number. In this case, 3.52 is closer to 4 than to 3, so the correct answer is 4.

    Rate this question:

  • 18. 

    In Python, a string literal is enclosed in __________.

    • A.

      Parentheses

    • B.

      Brackets

    • C.

      Single-quotes

    • D.

      Double-quotes

    Correct Answer
    C. Single-quotes
    Explanation
    In Python, a string literal is enclosed in single-quotes. This means that when declaring a string, it should be surrounded by single quotation marks (' '). For example, 'Hello World' is a string literal in Python. Using single-quotes is one of the ways to define a string and is commonly used in Python programming.

    Rate this question:

  • 19. 

    Suppose s is "\t\tWelcome\n", what is s.strip()?

    • A.

      \t\tWelcome\n

    • B.

      \t\tWelcome\n

    • C.

      \t\tWELCOME\n

    • D.

      Welcome

    Correct Answer
    D. Welcome
    Explanation
    The strip() method in Python removes any leading or trailing whitespace characters from a string. In this case, the string s is "\t\tWelcome", which has leading and trailing tabs and newlines. When we apply the strip() method to s, it removes these leading and trailing whitespace characters, resulting in the string "Welcome". Therefore, the correct answer is "welcome".

    Rate this question:

  • 20. 

    The following code displays ___________. temperature = 50 if temperature >= 100: print("too hot") elif temperature

    • A.

      Too hot

    • B.

      Too cold

    • C.

      just right

    • D.

      Too hot too cold just right

    Correct Answer
    C. just right
    Explanation
    The code will display "just right" because the temperature variable is set to 50, which is not greater than or equal to 100. Therefore, the if condition is not met and the code moves to the elif condition. Since there are no conditions specified for the elif statement, it will always be true and execute the following print statement, which is "just right".

    Rate this question:

  • 21. 

    How many times will the following code print "Welcome to Python"? count = 0 while count < 10: print("Welcome to Python") count += 1

    • A.

      8

    • B.

      9

    • C.

      10

    • D.

      11

    Correct Answer
    C. 10
    Explanation
    The given code will print "Welcome to Python" 10 times because the while loop will continue executing as long as the condition count < 10 is true. The count variable is initially set to 0, and each time the loop iterates, the count is incremented by 1. Therefore, the loop will run 10 times (count = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) and print "Welcome to Python" each time.

    Rate this question:

  • 22. 

    The function range(5) return a sequence ______________.

    • A.

      1, 2, 3, 4, 5

    • B.

      0, 1, 2, 3, 4, 5

    • C.

      1, 2, 3, 4

    • D.

      0, 1, 2, 3, 4

    Correct Answer
    D. 0, 1, 2, 3, 4
    Explanation
    The function range(5) returns a sequence starting from 0 up to, but not including, 5. So the correct answer is 0, 1, 2, 3, 4.

    Rate this question:

  • 23. 

    What is "Programming is fun"[4: 6]?

    • A.

      Ram

    • B.

      Ra

    • C.

      R

    • D.

      Pr

    Correct Answer
    B. Ra
    Explanation
    The expression "Programming is fun"[4:6] is using slicing in Python to extract a substring from the original string. In Python, indexing starts from 0, so the index 4 corresponds to the letter 'a' in the original string, and the index 6 is not included in the slice. Therefore, the substring extracted is "ra".

    Rate this question:

  • 24. 

    Given a string s = "Welcome", what is s.count('e')?

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    B. 2
    Explanation
    The count() function in Python is used to count the number of occurrences of a substring within a string. In this case, the string s is "Welcome" and we are counting the occurrences of the letter 'e'. Since 'e' appears twice in the string, the correct answer is 2.

    Rate this question:

  • 25. 

    Given a string s = "Programming is fun", what is s.find('m') ?

    • A.

      8

    • B.

      7

    • C.

      6

    • D.

      5

    Correct Answer
    C. 6
    Explanation
    The function s.find('m') returns the index of the first occurrence of the letter 'm' in the string s. In this case, the letter 'm' is located at index 6, so the correct answer is 6.

    Rate this question:

  • 26. 

    What is "Good".replace("o", "e")?

    • A.

      God

    • B.

      Good

    • C.

      Geed

    • D.

      Ged

    Correct Answer
    C. Geed
    Explanation
    When we replace the letter "o" with "e" in the word "Good", we get the word "Geed". This is because the letter "o" is substituted with the letter "e" in the word, resulting in the new word "Geed".

    Rate this question:

  • 27. 

    To return the length of string s, use _________.

    • A.

      S.__len__()

    • B.

      Len(s)

    • C.

      Size(s)

    • D.

      S.size()

    Correct Answer
    B. Len(s)
    Explanation
    The len(s) function is used to return the length of a string in Python. It takes the string as an argument and returns the number of characters in the string. Therefore, len(s) is the correct way to return the length of the string s.

    Rate this question:

  • 28. 

    How do you create a window?

    • A.

      window = newWindow()

    • B.

      Window = Window()

    • C.

      Window = Window()

    • D.

      window = Tk()

    Correct Answer
    D. window = Tk()
    Explanation
    The correct answer is "window = Tk()". This line of code creates a window using the Tkinter library in Python. Tkinter is a standard Python interface to the Tk GUI toolkit, and "Tk()" is a function that creates a new window object. By assigning this function call to the variable "window", we can then manipulate and customize the window as needed.

    Rate this question:

  • 29. 

    How do you create a frame?

    • A.

      Frame = newWindow()

    • B.

      Frame = Window()

    • C.

      Frame = Frame()

    • D.

      Frame = Tk()

    Correct Answer
    C. Frame = Frame()
    Explanation
    The correct answer is "frame = Frame()". This is because "Frame()" is a method in Python's tkinter module that creates a new window or frame. By assigning "frame" to "Frame()", we are creating a new frame object that can be used to build a graphical user interface. The other options, "newWindow()", "Window()", and "Tk()", do not exist as methods in the tkinter module and therefore would not create a frame.

    Rate this question:

  • 30. 

    How do you create a GUI component for displaying multiple-lines of text?

    • A.

      Use Label

    • B.

      Use Button

    • C.

      Use Text

    • D.

      Use Message

    Correct Answer
    D. Use Message
    Explanation
    To create a GUI component for displaying multiple lines of text, the appropriate option is to use the "Use Message" function. The Message function allows the user to display text that spans across multiple lines, making it suitable for displaying longer messages or paragraphs. This function is specifically designed to handle multi-line text and provides a convenient way to present information in a visually appealing format within a graphical user interface.

    Rate this question:

  • 31. 

    _______ are geometry managers in Tkinter.

    • A.

      Pack

    • B.

      Grid

    • C.

      Place

    • D.

      flow

    Correct Answer
    A. Pack
    Explanation
    In Tkinter, "pack" is one of the geometry managers. It is used to organize and arrange widgets in a block format, where each widget is placed below the previous one. The pack() method automatically adjusts the size of the widgets based on their content and fills the available space. It is a simple and easy-to-use geometry manager, making it suitable for basic GUI layouts.

    Rate this question:

  • 32. 

    To place a button in a specified row and column in its parent container, use ________.

    • A.

      Pack manager

    • B.

      Grid manager

    • C.

      Place manager

    • D.

      F+F34:F38low manager

    Correct Answer
    B. Grid manager
    Explanation
    To place a button in a specified row and column in its parent container, the appropriate manager to use is the grid manager. The grid manager allows for precise placement of widgets in a grid-like structure, where each widget can be positioned in a specific row and column. This ensures that the button will be placed exactly where desired within its parent container.

    Rate this question:

  • 33. 

    To create a menu in a window, use __________

    • A.

      Menubar = Menu(window)

    • B.

      Menubar = MenBar(window)

    • C.

      Menubar = Menu()

    • D.

      Menubar = MenBar()

    Correct Answer
    A. Menubar = Menu(window)
    Explanation
    To create a menu in a window, the correct way is to use "menubar = Menu(window)". This code creates a new menu bar object called "menubar" and associates it with the specified window. By passing the "window" parameter, it ensures that the menu bar is created within that specific window.

    Rate this question:

  • 34. 

    _____________ displays a file dialog for saving a file.

    • A.

      Filename = askopenfilename()

    • B.

      Filename = asksaveasfilename()

    • C.

      filename = openfilename()

    • D.

      Filename = saveasfilename()

    Correct Answer
    B. Filename = asksaveasfilename()
    Explanation
    The correct answer is "filename = asksaveasfilename()". This function is used to display a file dialog for saving a file. It allows the user to select a location and specify a file name for saving the file. The selected file name is then assigned to the variable "filename".

    Rate this question:

  • 35. 

    Invoking the ___________ method converts raw byte data to a string.

    • A.

      Encode()

    • B.

      Decode()

    • C.

      convert()

    • D.

      ToString()

    Correct Answer
    B. Decode()
    Explanation
    The decode() method is used to convert raw byte data to a string. This method is commonly used when working with encoded data, such as when decoding data received from a network or reading data from a file. By invoking the decode() method, the raw byte data is transformed into a readable string format that can be easily manipulated and understood by the programmer.

    Rate this question:

  • 36. 

    Which function do you use to read data using binary input?

    • A.

      read

    • B.

      Input

    • C.

      load

    • D.

      receive

    Correct Answer
    C. load
    Explanation
    The function "load" is used to read data using binary input. This function is commonly used to retrieve data from a binary file or to load binary data into a program. It allows the program to read the binary representation of the data and convert it into a usable format within the program.

    Rate this question:

  • 37. 

    Suppose s = {1, 2, 4, 3}, _______ returns 4.

    • A.

      sum(s)

    • B.

      Len(s)

    • C.

      Min(s)

    • D.

      Max(s)

    Correct Answer
    B. Len(s)
    Explanation
    The len(s) function returns the length of the given list or set. In this case, the set s has 4 elements, so len(s) will return 4.

    Rate this question:

  • 38. 

    Suppose s1 = {1, 2, 4, 3} and s2 = {1, 5, 4, 13}, what is s1 & s2?

    • A.

      {2, 3, 5, 13}

    • B.

      {1, 2, 4, 3, 5, 13}

    • C.

      {1, 4}

    • D.

      {1, 5, 4, 13}

    Correct Answer
    C. {1, 4}
    Explanation
    The correct answer is {1, 4}. This is because the "&" operator between two sets returns the intersection of the two sets, which is the set of elements that are common to both sets. In this case, the only elements that are present in both s1 and s2 are 1 and 4, so the intersection of s1 and s2 is {1, 4}.

    Rate this question:

  • 39. 

    Suppose d = {"john":40, "peter":45}, the keys are __________

    • A.

      John, 40, 45, and "peter"

    • B.

      John and "peter"

    • C.

      40 and 45

    • D.

      D = (40:"john", 45:"peter")

    Correct Answer
    B. John and "peter"
    Explanation
    The correct answer is "john and 'peter'". This is because in the given dictionary d = {"john":40, "peter":45}, "john" and "peter" are the keys of the dictionary. The keys in a dictionary are the unique identifiers for the values associated with them. In this case, the values associated with the keys "john" and "peter" are 40 and 45 respectively.

    Rate this question:

  • 40. 

    ________ is a data structure to store data in a sequential order.

    • A.

      A list

    • B.

      A set

    • C.

      A dictionary

    • D.

      A heap

    Correct Answer
    A. A list
    Explanation
    A list is a data structure that allows storing data in a sequential order. It is a collection of elements where each element has a specific position or index. The elements in a list can be accessed and manipulated individually by their index values. Unlike sets and dictionaries, which do not have a specific order, a list maintains the order in which the elements are added. A heap, on the other hand, is a specialized tree-based data structure used to efficiently retrieve the maximum or minimum element. Therefore, a list is the correct answer for storing data in a sequential order.

    Rate this question:

  • 41. 

    What is the number of edges in a complete graph of n vertices?

    • A.

      n

    • B.

      n - 1

    • C.

      N(n-1)/2

    • D.

      N*n

    Correct Answer
    C. N(n-1)/2
    Explanation
    A complete graph is a graph where each vertex is connected to every other vertex. In such a graph, the number of edges can be calculated using the formula n(n-1)/2, where n is the number of vertices. This formula is derived from the fact that each vertex is connected to n-1 other vertices, but we divide by 2 to avoid counting each edge twice. Therefore, the correct answer is n(n-1)/2.

    Rate this question:

  • 42. 

    Suppose a list is [2, 9, 5, 4, 8, 1]. After the first pass of bubble sort, the list becomes

    • A.

      2, 9, 5, 4, 8, 1

    • B.

      2, 9, 5, 4, 1, 8

    • C.

      2, 5, 9, 4, 8, 1

    • D.

      2, 5, 4, 8, 1, 9

    Correct Answer
    D. 2, 5, 4, 8, 1, 9

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 09, 2017
    Quiz Created by
    Catherine Halcomb
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.