Python Application Programming Quiz 1 : Klsvdit

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 Dr.RAMAKRISHNA
D
Dr.RAMAKRISHNA
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,530
| Attempts: 1,530 | Questions: 24
Please wait...
Question 1 / 24
0 %
0/100
Score 0/100
1. What is a correct syntax to output "Hello World" in Python?

Explanation

The correct syntax to output "Hello World" in Python is "print("Hello World")". This statement uses the print function in Python to display the specified text on the console.

Submit
Please wait...
About This Quiz
Python Application Programming Quiz 1 : Klsvdit - Quiz

The 'Python Application Programming Quiz 1: KLSVDIT' assesses foundational Python knowledge. It covers syntax, data types, and operations, testing comprehension through practical code snippets and theoretical questions. Ideal... see morefor beginners aiming to solidify their Python skills. see less

2. What is the correct syntax to output the type of a variable or object in Python?

Explanation

The correct syntax to output the type of a variable or object in Python is "print(type(x))". This will print the type of the variable or object stored in the variable "x".

Submit
3. How do you start writing an if statement in Python?

Explanation

The correct answer is "if x > y:". In Python, an if statement is started by using the keyword "if" followed by the condition that needs to be evaluated. The condition in this case is "x > y", which checks if the value of x is greater than the value of y. The colon at the end of the line indicates the start of the code block that will be executed if the condition is true.

Submit
4. Can we use the "else" clause for loops? for example:
for i in range(1, 5):
    print(i)
else:
    print("this is else block statement" )

Explanation

Yes, we can use the "else" clause for loops. In this example, the loop iterates over the range from 1 to 5. After the loop completes all iterations, the "else" block is executed, and the statement "this is else block statement" is printed. The "else" clause in a loop is executed only if the loop completes all iterations without encountering a "break" statement.

Submit
5. A string is immutable in Python? Every time when we modify the string, Python Always create a new String and assign a new string to that variable.

Explanation

In Python, strings are immutable, meaning that they cannot be changed once they are created. Whenever we modify a string, Python creates a new string and assigns it to a new variable, leaving the original string unchanged. This is why the statement "Every time when we modify the string, Python always creates a new string and assigns a new string to that variable" is true.

Submit
6. What is the correct way to create a function in Python?

Explanation

The correct way to create a function in Python is by using the "def" keyword followed by the function name and parentheses. This is the standard syntax for defining a function in Python.

Submit
7. What is the output of the following code? p, q, r = 10, 20 ,30 print(p, q, r)

Explanation

The given code assigns the values 10, 20, and 30 to the variables p, q, and r respectively. Then, it prints the values of p, q, and r which are 10, 20, and 30. Therefore, the output of the code is 10, 20, 30.

Submit
8. Which method can be used to replace parts of a string?

Explanation

The method "replace()" can be used to replace parts of a string. This method takes two parameters: the substring to be replaced and the substring to replace it with. It searches for all occurrences of the substring in the given string and replaces them with the new substring. This method is commonly used for tasks such as replacing certain characters or words within a string.

Submit
9. Which statement is used to stop a loop?

Explanation

The correct answer is "break". In programming, the "break" statement is used to terminate a loop prematurely. When the "break" statement is encountered within a loop, the loop is immediately exited, and the program continues executing from the next line after the loop. This is useful when a certain condition is met, and you want to stop the loop from further iterations.

Submit
10. What is the output of the following code
salary = 8000

def printSalary():
  salary = 12000
  print("Salary:", salary)
  
printSalary();
print("Salary:", salary)

Explanation

The code defines a variable "salary" with a value of 8000. Then, a function "printSalary()" is defined, which creates a new variable "salary" with a value of 12000 and prints it. When the function is called, it prints "Salary: 12000". After that, outside of the function, the original variable "salary" with a value of 8000 is printed, resulting in "Salary: 8000". Therefore, the output of the code is "Salary: 12000 Salary: 8000".

Submit
11. Which of these collections defines a LIST?

Explanation

The correct answer is [ "apple", "banana", "cherry" ] because it is enclosed in square brackets, which is the syntax for defining a list in many programming languages. Lists are ordered collections of items, and in this case, the list contains three strings: "apple", "banana", and "cherry". The other options are not valid syntax for defining a list.

Submit
12. What is the output of the following code? var1 = 1 var2 = 2 var3 = "3" print(var + var2 + var3)

Explanation

The code is attempting to concatenate a number and a string, which is not supported. This results in an error.

Submit
13. How do you create a variable with the floating number 2.8?

Explanation

The correct answer is that both the other answers are correct. This means that you can create a variable with the floating number 2.8 by either using the float() function or directly assigning the value 2.8 to the variable. Both methods will result in the variable holding the floating number 2.8.

Submit
14. Which one is NOT a legal variable name?

Explanation

The variable name "my-var" is not legal because it contains a hyphen. In most programming languages, hyphens are not allowed in variable names. Variables must typically consist of letters, numbers, and underscores, and they cannot start with a number. Therefore, "my-var" does not meet the criteria for a legal variable name.

Submit
15. Var = "KLS" * 2 * 3 print(var)

Explanation

The given code assigns the string "KLS" to the variable "var" and then multiplies it by 2 and 3. This means that the string "KLS" is repeated 2 times and then the resulting string is repeated 3 times. The final output is "KLSKLSKLSKLSKLSKLS".

Submit
16. What is a correct syntax to return the first character in a string?

Explanation

The correct syntax to return the first character in a string is "x = "Hello"[0]". This syntax uses indexing to access the first character of the string "Hello". The index 0 represents the first character in the string.

Submit
17. What is the output of the following x = 36 / 4 * (3 + 2) * 4 + 2 print(x)

Explanation

The correct answer is 182. This is because the expression follows the order of operations, which states that parentheses should be evaluated first, followed by multiplication and division from left to right, and finally addition and subtraction from left to right. In this case, the expression inside the parentheses, (3 + 2), evaluates to 5. Then, the division 36 / 4 is performed, resulting in 9. Next, the multiplication 9 * 5 * 4 is done, giving 180. Finally, the addition 180 + 2 is calculated, resulting in the final output of 182.

Submit
18. Which operator has higher precedence in the following list

Explanation

The ** operator, also known as the exponent operator, has higher precedence than the other operators in the given list. This means that any expression involving this operator will be evaluated before expressions involving the other operators.

Submit
19. Which of these collections defines a SET?

Explanation

The correct answer is {"apple", "banana", "cherry"}. This is because a set is an unordered collection of unique elements, and the given collection only contains unique elements and is enclosed in curly braces, which is the syntax for defining a set in many programming languages. The other options either contain duplicate elements or use different syntax, making them incorrect.

Submit
20. Which method can be used to return a string in upper case letters?

Explanation

The correct answer is "upper()". This method can be used to return a string in upper case letters.

Submit
21. Which of these collections defines a TUPLE?

Explanation

A tuple is defined by using parentheses, as shown in the correct answer. The other options use square brackets, curly braces, or a combination of curly braces and colons, which are not the correct syntax for defining a tuple.

Submit
22. What is the output of the following code?
listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]

print(listOne == listTwo)
print(listOne is listTwo)

Explanation

The output of the code is "True" and "False". The first print statement compares the values of the two lists, so it returns True because the values in both lists are the same. The second print statement uses the "is" operator to check if the two lists are the same object in memory, which is not the case here, so it returns False.

Submit
23. Which collection is ordered, changeable, and allows duplicate members?

Explanation

A list is an ordered collection in Python that allows duplicate elements and is changeable, meaning that elements can be added, removed, or modified. This makes it the correct answer for the given question. Sets, dictionaries, and tuples have different characteristics and do not meet all the requirements mentioned in the question.

Submit
24. What is the output of the following code? str = "pynative" print (str[1:3])

Explanation

The code is using string slicing to extract a portion of the string "pynative". The slicing syntax [1:3] means that it will start from the character at index 1 (inclusive) and go up to, but not including, the character at index 3 (exclusive). Therefore, the output will be "yn", which is the substring starting from index 1 and ending at index 2 in the original string.

Submit
View My Results

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

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

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 24, 2020
    Quiz Created by
    Dr.RAMAKRISHNA
Cancel
  • All
    All (24)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is a correct syntax to output "Hello World" in Python?
What is the correct syntax to output the type of a variable or object...
How do you start writing an if statement in Python?
Can we use the "else" clause for loops? ...
A string is immutable in Python? Every time when we modify the string,...
What is the correct way to create a function in Python?
What is the output of the following code? ...
Which method can be used to replace parts of a string?
Which statement is used to stop a loop?
What is the output of the following code ...
Which of these collections defines a LIST?
What is the output of the following code? ...
How do you create a variable with the floating number 2.8?
Which one is NOT a legal variable name?
Var = "KLS" * 2 * 3 print(var)
What is a correct syntax to return the first character in a string?
What is the output of the following...
Which operator has higher precedence in the following list
Which of these collections defines a SET?
Which method can be used to return a string in upper case letters?
Which of these collections defines a TUPLE?
What is the output of the following code? ...
Which collection is ordered, changeable, and allows duplicate members?
What is the output of the following code? ...
Alert!

Advertisement