0% found this document useful (0 votes)
10 views8 pages

Viva Therika Vidrom

The document provides an overview of Python programming concepts, including definitions of key terms such as variables, data types, loops, functions, and classes. It also explains important features like exception handling, file handling, and the use of built-in functions. Additionally, it covers advanced topics such as inheritance, encapsulation, and polymorphism.

Uploaded by

gocifo9880
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

Viva Therika Vidrom

The document provides an overview of Python programming concepts, including definitions of key terms such as variables, data types, loops, functions, and classes. It also explains important features like exception handling, file handling, and the use of built-in functions. Additionally, it covers advanced topics such as inheritance, encapsulation, and polymorphism.

Uploaded by

gocifo9880
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Viva Therika Vidrom

1. What is Python?

- A high-level, interpreted programming language known for its simplicity.

2. What is the difference between an interpreter and a compiler?

- An interpreter executes code line by line, while a compiler converts the whole program into machine code at

once.

3. What is a variable?

- A named location in memory to store data.

4. What is a constant?

- A value that does not change during program execution.

5. What are Python keywords?

- Reserved words with special meanings in Python, e.g., if, for, while.

6. What is a data type?

- Specifies the kind of data a variable can hold, e.g., int, float, str.

7. What are the basic data types in Python?

- int, float, str, bool, list, tuple, dict.

8. What is a string?

- A sequence of characters enclosed in quotes (" " or ' ').


9. What is type casting?

- Converting one data type to another, e.g., int("10").

10. What is the type() function?

- Returns the data type of a variable.

11. What is the purpose of the id() function?

- Returns the memory address of a variable.

12. What is a list in Python?

- An ordered, mutable collection of items.

13. What is a tuple?

- An ordered, immutable collection of items.

14. What is a dictionary?

- A collection of key-value pairs.

15. What is a set in Python?

- An unordered collection of unique elements.

16. What is a loop?

- A structure that executes a block of code repeatedly.

17. What is a for loop?

- Executes a block of code for each item in a sequence.


18. What is a while loop?

- Executes a block of code while a condition is true.

19. What is the difference between break and continue?

- break: Exits the loop.

- continue: Skips the current iteration and continues the loop.

20. What is the pass statement?

- A placeholder that does nothing and is used to maintain the structure of a program.

21. What is a function?

- A block of reusable code that performs a specific task.

22. What is the purpose of the def keyword?

- Used to define a function.

23. What is the return value of a function?

- The value that a function sends back after execution using the return statement.

24. What are arguments in Python?

- Values passed to a function when it is called.

25. What are default arguments?

- Arguments that take predefined values if no value is provided during function call.

26. What is recursion?


- A function calling itself to solve smaller instances of the same problem.

27. What is a module?

- A file containing Python code that can be imported into another program.

28. What is the math module?

- A Python module with mathematical functions like sqrt(), sin(), etc.

29. What is file handling?

- Reading and writing to files.

30. What are the modes in file handling?

- r (read), w (write), a (append), rb (read binary), etc.

31. What is the with statement?

- Simplifies file handling and ensures files are properly closed after operations.

32. What is the purpose of the open() function?

- Opens a file for reading, writing, or appending.

33. What is exception handling?

- Managing errors during program execution.

34. What is the try block?

- Contains code that might raise an exception.

35. What is the except block?


- Handles exceptions that occur in the try block.

36. What is the difference between mutable and immutable objects?

- Mutable: Can be changed (e.g., lists).

- Immutable: Cannot be changed (e.g., strings, tuples).

37. What is a class?

- A blueprint for creating objects.

38. What is an object?

- An instance of a class.

39. What is the self keyword?

- Represents the instance of the class in methods.

40. What is inheritance in Python?

- A feature that allows a class to inherit properties and methods from another class.

41. What is a constructor?

- A special method (__init__) that initializes an object.

42. What is encapsulation?

- Restricting access to certain details of an object to protect data.

43. What is polymorphism?

- A feature that allows a function or method to behave differently based on input or context.
44. What is an iterator?

- An object that allows sequential traversal of a collection.

45. What is a generator?

- A function that returns an iterator and uses yield instead of return.

46. What is the purpose of the lambda keyword?

- Creates anonymous (nameless) functions.

47. What is the map() function?

- Applies a function to every item in a sequence.

48. What is the filter() function?

- Filters items in a sequence based on a condition.

49. What is the zip() function?

- Combines multiple iterables into one.

50. What is the enumerate() function?

- Adds a counter to an iterable.

51. What is a package?

- A collection of related Python modules.

52. What is the difference between a shallow copy and a deep copy?

- Shallow Copy: Creates a new object but references the original elements.

- Deep Copy: Creates a new object and recursively copies all elements.
53. What is the purpose of the is operator?

- Checks if two objects have the same memory location.

54. What is the difference between is and ==?

- is: Checks object identity.

- ==: Checks object value.

55. What is the purpose of the not operator?

- Returns the opposite boolean value.

56. What is the len() function?

- Returns the number of items in an object (e.g., a string, list).

57. What is the sorted() function?

- Returns a sorted list from the input iterable.

58. What is the difference between sort() and sorted()?

- sort(): Modifies the original list.

- sorted(): Returns a new sorted list.

59. What is the difference between append() and extend() in lists?

- append(): Adds a single item to the end of the list.

- extend(): Adds multiple items to the list.

60. What is the difference between pop() and remove() in lists?

- pop(): Removes an item by index.


- remove(): Removes the first occurrence of a specified value.

You might also like