.
PY VIVA QUESTIONS AND ANSWERS
1) Who is the creator of Python?
→ Guido van Rossum.
2) In which year was Python first released?
→ 1991.
3) Why is Python called a high-level language?
→ Because it is close to human language and easy to read/write.
4) What is the main advantage of Python?
→ Simplicity, readability, and vast library support.
5) What are Identifiers in Python?
→ User-defined names for variables, functions, etc.
6) What are Keywords in Python?
→ Reserved words with predefined meanings.
7) What are Variables in Python?
→ Named memory locations used to store data.
8) What is the difference between Statement and Expression?
→ Statement = complete instruction, Expression = produces a value.
9) What is Anaconda used for?
→ Managing Python packages, environments, and Data Science tools.
10) What is Jupyter Notebook?
→ An interactive tool for coding, visualization, and documentation.
11) What are Data Types in Python?
→ Built-in types like int, float, str, list, tuple, dict, set.
12) What is Type Conversion in Python?
→ Converting one data type into another using functions like int(), str().
13) What does the type() function do?
→ Returns the data type of a variable.
14) What is the use of the is operator?
→ To check whether two objects have the same identity (memory).
15) What is the difference between Dynamic and Strong Typing?
→ Dynamic = type decided at runtime; Strong = prevents mixing incompatible types.
16) What is Indentation in Python?
→ Spaces/tabs used to define code blocks (instead of {}).
17) What are Control Flow Statements?
→ Statements like if, else, while, for, break, continue that control execution.
18) What is the use of continue and break?
→ continue skips current iteration, break exits the loop completely.
19) What is a function in Python?
→ A block of reusable code that performs a specific task.
20) What is the difference between built-in and user-defined functions?
→ Built-in functions are pre-defined (len(), sum()), while user-defined are written by programmers.
21) What does the return statement do?
→ It sends a value back from a function to the caller.
22) How are strings stored in Python?
→ Strings are stored as sequences of Unicode characters.
23) How can you access characters of a string?
→ By using index numbers (e.g., s[0] for the first character).
24) What is string slicing?
→ Extracting a substring using [start:end].
25) What are some common string methods?
→ upper(), lower(), strip(), replace(), split().
26) What is a list in Python?
→ A mutable ordered collection of items.
27) What are some commonly used built-in list functions?
→ len(), sum(), max(), min(), sorted().
28) What is a dictionary in Python?
→ A collection of key–value pairs enclosed in {}.
29) What is a tuple in Python?
→ An immutable ordered collection of elements enclosed in ().
30) Can tuples store different data types?
→ Yes, tuples can store integers, strings, lists, etc.
31) What is the difference between a list and a tuple?
→ Lists are mutable, tuples are immutable.
32) What built-in functions can be used on tuples?
→ len(), min(), max(), sum(), sorted().
33) What is a set in Python?
→ An unordered collection of unique elements enclosed in {}.
34) How do you create an empty set?
→ s = set() (not {}, which creates a dictionary).
35) Name two common set methods.
→ union(), intersection(), difference(), add(), remove().