Code Execution Championship-round 1 -python

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 1443 | Total Attempts: 6,714,231
| Attempts: 568 | Questions: 42
Please wait...
Question 1 / 42
0 %
0/100
Score 0/100
1. What is max(3, 5, 1, 7, 4)?

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.

Submit
Please wait...
About This Quiz
Code Execution Championship-round 1 -python - Quiz

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.

Personalize your quiz and earn a certificate with your name on it!
2. The function range(5) return a sequence ______________.

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.

Submit
3. To return the length of string s, use _________.

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.

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

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".

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

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.

Submit
6. Which of these in not a core datatype?

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.

Submit
7. Which of these is not a core data type?

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.

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

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.

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

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.

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

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.

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

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.

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

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".

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

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.

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

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.

Submit
15. How do you create a window?

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.

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

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.

Submit
17. Which of the following is correct about Python?

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.

Submit
18. What is round(3.52)?

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.

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

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.

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

Explanation

The given code will print "Welcome to Python" 10 times because the while loop will continue executing as long as the condition count

Submit
21. To create a menu in a window, use __________

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.

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

Explanation

not-available-via-ai

Submit
23. How do you create a 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.

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

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.

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

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.

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

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.

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

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".

Submit
28. What is the return value of trunc() ?

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.

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

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".

Submit
30. What is "Programming is fun"[4: 6]?

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".

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

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.

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

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.

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

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.

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

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}.

Submit
35. Which of the following is correct about Python?

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.

Submit
36. _______ are geometry managers in Tkinter.

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.

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

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.

Submit
38. _____________ displays a file dialog for saving a file.

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".

Submit
39. In Python, a string literal is enclosed in __________.

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.

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

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.

Submit
41. Which of the following is correct about tuples in python?

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."

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

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.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 18, 2023 +

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
Cancel
  • All
    All (42)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is max(3, 5, 1, 7, 4)?
The function range(5) return a sequence ______________.
To return the length of string s, use _________.
What is "Good".replace("o", "e")?
Which of the following functions is a built-in function in python?
Which of these in not a core datatype?
Which of these is not a core data type?
In order to store values in terms of key and value we use what core...
Given a string s = "Welcome", what is s.count('e')?
To place a button in a specified row and column in its parent...
Which of the following operator in python evaluates to true if it does...
Suppose s is "\t\tWelcome\n", what is s.strip()?
Given a string s = "Programming is fun", what is s.find('m') ?
What is the number of edges in a complete graph of n vertices?
How do you create a window?
________ is a data structure to store data in a sequential order.
Which of the following is correct about Python?
What is round(3.52)?
What is the following function returns the lowest index in list that...
How many times will the following code print "Welcome to Python"?...
To create a menu in a window, use __________
Suppose a list is [2, 9, 5, 4, 8, 1]. After the first pass of bubble...
How do you create a frame?
Suppose d = {"john":40, "peter":45}, the keys are __________
Which of the following function convert a String to an object in...
Given a function that does not return any value, what value is shown...
Given a function that does not return any value, What value is thrown...
What is the return value of trunc() ?
The following code displays ___________....
What is "Programming is fun"[4: 6]?
Suppose s = {1, 2, 4, 3}, _______ returns 4.
How many keyword arguments can be passed to a function in a single...
What does the following code do?→def a(b, c, d): pass
Suppose s1 = {1, 2, 4, 3} and s2 = {1, 5, 4, 13}, what is s1 & s2?
Which of the following is correct about Python?
_______ are geometry managers in Tkinter.
Invoking the ___________ method converts raw byte data to a string.
_____________ displays a file dialog for saving a file.
In Python, a string literal is enclosed in __________.
How do you create a GUI component for displaying multiple-lines of...
Which of the following is correct about tuples in python?
Which function do you use to read data using binary input?
Alert!

Advertisement