PYTHON REVISION TOUR - I VIVA

1. What is a character set in Python?
Ans :- The set of valid characters that Python recognizes for writing programs, including letters, digits, and symbols.
 
2. List some commonly used characters in Python.
Ans :- Letters (a-z, A-Z), digits (0-9), special symbols (+, -, *, /), and whitespace characters (space, tab, newline).
 
3.Is Python case-sensitive?  
Ans :-  Yes, Python distinguishes between uppercase and lowercase letters.
 
4. What is the use of whitespace in Python?**  
Ans :- Whitespace is used for indentation and separating tokens.
 
5. What are tokens in Python? 
Ans :- Tokens are the smallest units of a program, such as keywords, identifiers, literals, operators, and punctuators.
 
6.What are Python keywords?  
Ans :- Reserved words in Python with special meanings (e.g., `if`, `else`, ‘while’, ‘for’, etc.).
 
7. What is an identifier?
Ans :- A name used to identify variables, functions, or classes.
8. What are literals in Python?  
Ans :- Fixed values in a program, such as numbers (`123`), strings (`”Hello”`), or booleans (`True`, `False`).
9.What are operators?
Ans :- Symbols used to perform operations (e.g., `+`, `-`, `*`, `/`, `==`).
10. What are punctuators in Python? 
Ans :- Symbols like `,`, `:`, `[]`, `{}`, used to structure code.
11. What are the components of a basic Python program?  
Ans :- Comments, statements, functions, and blocks.
12. What is the significance of indentation in Python? 
Ans :- Indentation defines the block of code and is mandatory for structuring.
13. How do you write comments in Python?
Ans Single-line comments use `#`. Multi-line comments use triple quotes (`”””` or `”’`).
14. What is the main function in Python? 
Ans :- It’s the entry point for execution, written as:  
      if __name__ == “__main__”:
main()
 15. What is a variable in Python? 
Ans :- A name that refers to a value stored in memory.
16. How do you assign a value to a variable?  
Ans :- Using the assignment operator `=`.   x = 10
17. What are dynamic variables? 
Ans :- Variables that can change their type during runtime in Python.
18. Can variable names start with a number? 
Ans :- No, variable names must start with a letter or underscore.
19. What is multiple assignment?
Ans :- Assigning multiple variables in a single line.   a, b, c = 1, 2, 3
20. How do you take input from the user in Python?
Ans :- input_value = input(“Enter something: “)
21. What is the default type of `input()`?  
Ans :- String.
22. How do you print output in Python?**  
Ans :- print(“Hello, World!”)
23. How can you format strings in `print()`?  
Ans :- Using `f-strings` or `.format()`.  
print(f”My name is {name}”)
24. What are Python’s basic data types?  
Ans :- `int`, `float`, `str`, `bool`, `list`, `tuple`, `set`, `dict`.
25. What is the difference between `list` and `tuple`? 
Ans :- `list` is mutable; `tuple` is immutable.
26. What is a dictionary in Python? 
Ans :- A collection of key-value pairs.  
d = {“name”: “Alice”, “age”: 25}
27. What are mutable data types?  
Ans :- Data types that can be modified (e.g., `list`, `dict`, `set`).
28. What are immutable data types?  
Ans :- Data types that cannot be modified (e.g., `int`, `float`, `tuple`, `str`).
29. What is an expression in Python?
Ans :- A combination of variables, operators, and values that evaluates to a result.
30. What is the result of `2 + 3 * 4` in Python? 
Ans :- `14`, because of operator precedence.
31. What is type conversion? 
Ans :- Converting one data type into another.   int(“123”)
32. What is the difference between implicit and explicit conversion?**  
Ans :- Implicit is done automatically by Python; explicit requires manual conversion.
33. What are Python statements?
Ans :- Instructions executed by Python (e.g., assignment, conditional, loop).
34. What is a compound statement? 
Ans :- A statement that contains multiple instructions, like `if`, `for`, `while`.
35. What are IDEs, and give examples?  
Ans :- Integrated Development Environments, such as PyCharm, Jupyter, and VS Code.
36. What are control structures in Python?  
Ans :- Constructs like `if`, `for`, and `while` that control the flow of execution.
37. What is the syntax of an `if` statement?  
Ans :- if condition:
 38.What is the difference between `for` and `while` loops? 
Ans :- `for` is used for iterating over a sequence; `while` is used for repeated execution based on a condition.
39. What are jump statements in Python?  
Ans :- Statements like `break`, `continue`, and `pass` that alter the flow of execution.
40.What does the `break` statement do?  
Ans :- Exits the current loop prematurely.

Leave a Reply

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

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.