0% found this document useful (0 votes)
13 views

Untitled document

Uploaded by

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

Untitled document

Uploaded by

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

Here are the answers to all the questions:

---

1. Describe about your project

Modules/Packages used: Mention the specific Python libraries (e.g., mysql.connector, os,
pandas, etc.).

Number of tables used: State how many tables are in the database for the project and their
purpose.

---

PYTHON-MYSQL CONNECTOR

2. Which module is used to connect Python & MySQL?

mysql.connector

3. What is .connect()?

Establishes a connection between Python and the MySQL database.

4. What is .cursor()?

Creates a cursor object, which is used to execute SQL queries.

5. What is .commit()?

Saves changes made to the database permanently.

6. .fetchall() / .fetchone() / .fetchmany()?

fetchall(): Fetches all rows from the result.

fetchone(): Fetches the next single row from the result.


fetchmany(size): Fetches the next size rows from the result.

7. What is .rowcount?

Returns the number of rows affected by the last executed query.

8. What is a format specifier?

A placeholder in a string that specifies the format of a value (e.g., %s for strings in SQL
queries).

---

DATABASE & MYSQL

9. Difference between DBMS & RDBMS?

DBMS: Manages databases, lacks relationships.

RDBMS: Manages relational databases with structured data and relations.

10. What are attribute, tuple, field, degree, cardinality?

Attribute: A column in a table.

Tuple: A row in a table.

Field: A single data value in a table.

Degree: Number of attributes in a table.

Cardinality: Number of rows in a table.

11. Candidate key, alternate key, foreign key, primary key?


Candidate key: All possible keys that can uniquely identify a row.

Primary key: The main key selected from candidate keys.

Alternate key: Candidate keys not chosen as the primary key.

Foreign key: A field in one table referencing a primary key in another.

12. What is DDL, DML, DCL, TCL & their commands?

DDL (Data Definition Language): Defines database structure (CREATE, DROP, ALTER).

DML (Data Manipulation Language): Manipulates data (INSERT, UPDATE, DELETE).

DCL (Data Control Language): Controls access (GRANT, REVOKE).

TCL (Transaction Control Language): Manages transactions (COMMIT, ROLLBACK).

13. Difference between char & varchar?

char: Fixed-length string.

varchar: Variable-length string.

14. What are constraints?

Rules enforced on table columns:

NOT NULL: No null values allowed.

UNIQUE: Ensures all values in a column are unique.

PRIMARY KEY: Combines NOT NULL and UNIQUE.

15. Difference between DELETE & TRUNCATE?

DELETE: Removes rows based on condition; can roll back.

TRUNCATE: Removes all rows; cannot roll back.


16. DROP vs DELETE

DROP: Deletes entire table or database.

DELETE: Deletes specific rows.

17. DISTINCT & UNIQUE

DISTINCT: Eliminates duplicate rows in a query result.

UNIQUE: Ensures uniqueness in a column.

18. GROUP BY & ORDER BY

GROUP BY: Groups rows sharing a value.

ORDER BY: Sorts rows in ascending/descending order.

19. HAVING & WHERE

HAVING: Filters groups.

WHERE: Filters rows before grouping.

20. Equi-join & Natural join

Equi-join: Joins tables using an equality condition.

Natural join: Joins tables automatically matching columns with the same name.

21. Aggregate functions?

Functions like SUM(), AVG(), COUNT(), MAX(), MIN() to perform calculations on data.
---

FILE HANDLING

22. Difference between text file, binary file, CSV file?

Text file: Stores plain text.

Binary file: Stores data in binary format.

CSV file: Stores tabular data in text format with comma-separated values.

23. Relative path vs absolute path?

Relative path: Path relative to the current working directory.

Absolute path: Complete path from the root directory.

24. What is with clause?

Manages file opening/closing automatically in Python.

25. What is .readline() / .read() / .readlines()?

.readline(): Reads one line at a time.

.read(): Reads entire file.

.readlines(): Reads all lines into a list.

26. What is pickle?

A module for serializing and deserializing Python objects.

27. dump vs load?


dump: Serializes and saves objects to a file.

load: Reads and deserializes objects from a file.

28. try & except?

Handles exceptions in Python.

29. What is CSV?

A file format to store tabular data in plain text separated by commas.

30. Workbook vs Worksheet?

Workbook: An Excel file.

Worksheet: A single sheet within a workbook.

31. .writerow() vs .writerows()?

.writerow(): Writes one row to a CSV file.

.writerows(): Writes multiple rows to a CSV file.

---

FUNCTIONS

32. What are functions?

Reusable blocks of code to perform specific tasks.

33. What is the return statement?


Returns a value from a function.

34. Difference between parameters & arguments?

Parameters: Defined in the function definition.

Arguments: Passed to the function during a call.

35. Default parameters?

Parameters with default values if no argument is provided.

36. Global vs local scope?

Global scope: Accessible anywhere.

Local scope: Accessible within a function or block.

---

DATA STRUCTURES

37. What is STACK?

A LIFO (Last In, First Out) data structure.

38. PUSH vs POP

PUSH: Adds an element to the stack.

POP: Removes the top element.

39. Difference between QUEUE & STACK?


QUEUE: FIFO (First In, First Out).

STACK: LIFO.

40. What is Underflow?

Trying to remove an element from an empty stack.

41. What is Top?

Refers to the topmost element of the stack.

42. What is Peek?

Returns the topmost element without removing it.

---

PYTHON REVISION TOPICS

43. What are keywords?

Reserved words in Python with predefined meanings.

44. Mutable vs Immutable (with examples)?

Mutable: Can be modified (e.g., lists, dictionaries).

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

45. Explicit vs Implicit type conversion?

Explicit: Manual conversion using int(), float().


Implicit: Automatic conversion by Python.

46. What is split()?

Splits a string into a list based on a delimiter.

47. Append() vs Pop() (Lists)?

append(): Adds an element to the list.

pop(): Removes and returns the last element.

48. What is sorted()?

Returns a sorted version of a list.

49. Tuple vs List vs Dictionary?

Tuple: Immutable, ordered.

List: Mutable, ordered.

Dictionary: Mutable, unordered key-value pairs.

50. Single element tuple?

Tuple with one element: (element,).

51. Keys vs Values in Dictionary?

Keys: Unique identifiers for values.

Values: Data stored in the dictionary.


52. Update in Dictionary?

Updates or adds key-value pairs using update() method.

You might also like