Python Viva Questions With Answers
Python Viva Questions With Answers
import pandas as pd
df = pd.DataFrame(data)
5. How do you label the axes and set a title for a chart in
matplotlib?
Answer: You can use xlabel(), ylabel(), and title() methods. For
example:
plt.xlabel("X-axis Label")
plt.ylabel("Y-axis Label")
plt.title("Chart Title")
a = 10
b=5
print(a + b) # Addition
print(a - b) # Subtraction
o Remove duplicates.
o Normalize/standardize data.
o Remove outliers.
-Specific Questions
try:
cursor.execute(" Query")
except Exception as e:
print("Error:", e)
-Specific Questions
SELECT Recipes.recipe_name
FROM Recipes
INNER JOIN Ingredients
ON Recipes.recipe_id = Ingredients.recipe_id
Integration Questions
Advanced Questions
4. How would you scale this project for a larger user base?
Answer: By:
-Specific Questions
try:
cursor.execute(" Query")
except Exception as e:
print("Error:", e)
-Specific Questions
Advanced Questions
f.write('%s\n' % line)
-Specific Questions
-Specific Questions
FROM Attendance
WHERE MONTH(date) = 1
GROUP BY employee_id;
Integration Questions
try:
cursor.execute(" Query")
except Exception as e:
print("Database Error:", e)
import pandas as pd
data.to_csv("attendance_report.csv", index=False)
Advanced Questions
5. How can this system handle shifts and flexible working hours?
Answer: By adding a shift column in the database and adjusting
attendance validations according to the shift timings.
TO DO LIST
o Deleting tasks.
if not task_name.strip():
-Specific Questions
Integration Questions
if len(task_name) == 0:
Advanced Questions
import pandas as pd
data.to_csv("task_list.csv", index=False)
5. How do you ensure that completed tasks are not shown in the
pending list?
Answer: By filtering tasks based on their status field in queries.
ECOMMERCE PLATFORM
-Specific Questions
if not email.endswith("@example.com"):
-Specific Questions
FROM Cart
WHERE Cart.user_id = ?;
Integration Questions
try:
connection.commit()
except Exception as e:
connection.rollback()
print("Error:", e)
FROM Orders
GROUP BY product_id
Advanced Questions
1. How would you scale this platform for more users and
products?
Answer: By optimizing the database with indexing, partitioning tables,
and using cloud-based database solutions.
WEATHER FORECAST:
General Questions about the Project
-Specific Questions
5. Can you show an example of how you retrieve weather data for
a specific date?
Answer:
date = '2025-01-20'
result = cursor.fetchall()
-Specific Questions
o date (DATE)
o location (VARCHAR)
o temperature (FLOAT)
o humidity (INT)
o wind_speed (FLOAT)
o description (VARCHAR)
3. How do you retrieve the weather data for a specific city and
date?
Answer: Using an query:
FROM Weather
Integration Questions
try:
connection.commit()
except Exception as e:
connection.rollback()
print("Error:", e)
rows = cursor.fetchall()
Advanced Questions
1. How does your system handle missing or incomplete data?
Answer: Missing data is handled using default values or by skipping
entries with incomplete data.
-Specific Questions
connection.commit()
4. How is the bug status updated in your system?
Answer: By using UPDATE queries through .
Example:
connection.commit()
unresolved_bugs = cursor.fetchall()
print(bug)
-Specific Questions
o project_name (VARCHAR)
o description (VARCHAR)
o severity (VARCHAR)
o status (VARCHAR)
o assigned_to (VARCHAR)
o created_on (DATE)
Integration Questions
1. How does interact with your database?
Answer: interacts with using libraries like ite3 or my.connector to
execute queries for CRUD operations.
Advanced Questions
FITNESS TRACKER:
-Specific Questions
try:
connection = ite3.connect("fitness.db")
cursor = connection.cursor()
# operations
except ite3.Error as e:
print(f"Error: {e}")
finally:
connection.close()
-Specific Questions
o date (DATE)
o activity_type (VARCHAR)
o duration (INT)
o calories_burned (INT)
SELECT SUM(calories_burned)
FROM Activities
SELECT user_id
FROM Users
FROM Activities
);
Integration Questions
Advanced Questions