Assignment 1
Q1. Python Program to Find if a Number is Even or Odd
```python
# Program to check if the number is even or odd
num = int(input("Enter a number: "))
if num % 2 == 0:
print(f"{num} is Even")
else:
print(f"{num} is Odd")
```
------------------------------------------------------------
Q2. Python Program to Find the Fibonacci Series up to 100
```python
# Program to generate Fibonacci series up to 100
a, b = 0, 1
print("Fibonacci series up to 100:")
while a <= 100:
print(a, end=" ")
a, b = b, a + b
```
------------------------------------------------------------
Q3. Python Program to Read a CSV File and Visualize Data
```python
# Make sure to install pandas and matplotlib before running:
# pip install pandas matplotlib
import pandas as pd
import matplotlib.pyplot as plt
# Read CSV file (replace 'data.csv' with your file path)
file_path = 'data.csv' # Example: 'C:/Users/YourName/Downloads/data.csv'
data = pd.read_csv(file_path)
# Display the first few rows
print("Data Preview:")
print(data.head())
# Visualization examples (adjust based on your CSV columns)
# 1. Line plot
data.plot()
plt.title("Line Plot of All Numeric Columns")
plt.show()
Assignment 1
# 2. Histogram of a specific column (replace 'ColumnName')
if 'ColumnName' in data.columns:
data['ColumnName'].hist(bins=10)
plt.title("Histogram of ColumnName")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
# 3. Bar plot of first 10 rows for a column (adjust names as needed)
if 'XColumn' in data.columns and 'YColumn' in data.columns:
data.head(10).plot(kind='bar', x='XColumn', y='YColumn')
plt.title("Bar Chart of First 10 Entries")
plt.show()
```