CBSERanker

Loading

Worksheet Introduction to Python

Worksheet Introduction to Python

Choose the correct answer

What is the correct way to start an interactive mode session in Python?

  • A) python start
  • B) python
  • C) start python
  • D) install python

Which of the following file extensions is used for Python script files?

  • A) .py
  • B) .txt
  • C) .pys
  • D) .python

How does Python treat indentation?

  • A) As a part of syntax
  • B) As a recommendation
  • C) For improving readability only, no syntax significance
  • D) Python ignores all spaces and tabs

Which of the following is a valid identifier in Python?

  • A) 2things
  • B) thing2
  • C) -thing
  • D) None of the above

What defines a keyword in Python?

  • A) A user-defined name
  • B) Identifiers that cannot be used as variable names
  • C) Variables that store data values
  • D) A type of operator

What type of value does a constant hold in Python?

  • A) Changeable value
  • B) Temporary data
  • C) An immutable value
  • D) None of the above

What does the ‘==’ operator check?

  • A) Assignment
  • B) Equality
  • C) Identity
  • D) Inequality

Which operator has the highest precedence in Python?

  • A) *
  • B) +
  • C) =
  • D) %

Which data type is immutable?

  • A) List
  • B) Dictionary
  • C) Tuple
  • D) Set

Which is a mutable data type?

  • A) String
  • B) Tuple
  • C) Frozenset
  • D) List

What will be the output of the expression ‘2+3*4’?

  • A) 20
  • B) 14
  • C) 11
  • D) 24

Which statement is used to stop a loop in Python?

  • A) stop
  • B) break
  • C) pause
  • D) exit

Which of the following is used to evaluate a variable’s value within an expression in Python?

  • A) eval()
  • B) assert
  • C) exec()
  • D) estimate()

What is the purpose of ‘#’ in Python?

  • A) Start a new line
  • B) Create a list
  • C) Comment a line
  • D) Denote a hexadecimal number

How do you read input as a string in Python?

  • A) input()
  • B) get()
  • C) read()
  • D) scan()

Which function converts a string into an integer?

  • A) int()
  • B) str()
  • C) float()
  • D) chr()

Which statement is correct about Python debugging?

  • A) Debugging is only possible in integrated development environments.
  • B) Python does not allow debugging.
  • C) Print statements are often used for debugging in Python.
  • D) Debugging is automatically done by Python.

What does the ‘if-else’ statement do in Python?

  • A) Checks whether a program is correct
  • B) Decides between two alternatives
  • C) Loops through a block of code
  • D) None of the above

How do you start a ‘for’ loop in Python?

  • A) for each element in sequence:
  • B) for element = start to end:
  • C) for i in range(10):
  • D) for i < 10:

What is the output of ‘print(type(1))’?

  • A) int
  • B) <class ‘int’>
  • C) number
  • D) <type ‘int’>

Which Python statement checks multiple conditions?

  • A) if
  • B) elif
  • C) else
  • D) when

What is not a core data type in Python?

  • A) Lists
  • B) Dictionary
  • C) Custom
  • D) Tuples

Which of the following correctly creates a comment in Python?

  • A) /* Comment */
  • B) // Comment
  • C) # Comment
  • D) – Comment

What does ‘input()’ do in Python?

  • A) Display output
  • B) Read a line from input
  • C) Declare a variable
  • D) Define a function

Which is the correct way to handle both input and data conversion at once?

  • A) x = int(input())
  • B) x = input(int)
  • C) x = int(input(“Enter a number”))
  • D) x = input()

What is the outcome of this code: ‘print(10 / 3)’?

  • A) 3
  • B) 3.3333…
  • C) 3.3
  • D) 3.0

Which of these is not a logical operator in Python?

  • A) and
  • B) or
  • C) not
  • D) nand

Which keyword is used for defining a function in Python?

  • A) func
  • B) define
  • C) def
  • D) function

How do you concatenate strings in Python?

  • A) +
  • B) &
  • C) concat()
  • D) append()

What does the ‘while’ loop do in Python?

  • A) Runs a block of code a single time
  • B) Runs a block of code a fixed number of times
  • C) Executes a block of code as long as the condition is true
  • D) Checks a condition at the end of the loop

Write answer

  1. Explain the concept of indentation in Python and its importance in the structure of a Python program.
  2. Describe how input and output operations are performed in Python with examples.
  3. Discuss the different types of operators in Python and explain the precedence of operators with examples.
  4. Explain the ‘if-elif-else’ control structure in Python with an example to demonstrate its usage in making decisions.

Leave a Reply

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