Kushal - Project
Kushal - Project
CLASS-12THC1
ROLL NO-04
Question: Write an SQL query to fetch the EmpId and FullName of
all the employees working under the Manager with id – ‘986’.
Query:
Output:
EmpId FullName
Query:
Output:
P1
P2
P3
Question: Write an SQL query to fetch the count of employees
working in project ‘P1’.
Query:
SELECT COUNT(*)
2FROM EmployeeSalary
3WHERE Project = 'P1';
Output:
COUNT(*)
5
Question: Write an SQL query to find the maximum, minimum,
and average salary of the employees.
Query:
Output:
sql
Query:
Output:
Question: Write an SQL query to fetch all the employees who are not
working on any project.
sql
Query:
SELECT EmpId
2FROM EmployeeSalary
3WHERE Project IS NULL;
Output:
EmpId
301
302
Query:
EmpId Salary
401 12000
402 11000
Query:
SELECT *
2FROM Student
3WHERE FIRST_NAME LIKE '%a';
Output:
sql
Query:
SELECT *
2FROM Student
3WHERE GPA BETWEEN 9.00 AND 9.99;
Output:
Query:
SELECT *
2FROM Student
3WHERE FIRST_NAME IN ('Prem', 'Shivansh');
Output:
Query:
SELECT EmpId, FullName
2FROM EmployeeDetails
3WHERE Salary > 80000;
Output:
EmpId FullName
Query:
SELECT EmpId, FullName
2FROM EmployeeDetails
3WHERE Department = 'IT' AND Salary > 60000;
Output:
EmpId FullName
Query:
SELECT EmpId, FullName
2FROM EmployeeDetails
3ORDER BY Salary DESC;
Output:
EmpId FullName
Output:
Department EmployeeCount
IT 3
HR 2
Finance 2
SELECT *
2FROM EmployeeDetails
3WHERE LastName = 'Smith';
Output:
def reverse_string(s):
2 return s[::-1]
3
4# Example usage
5print(reverse_string("hello")) # Output:
"olleh"
Q: Write a function to check if a string is
a palindrome.
Code:
def is_palindrome(s):
2 return s == s[::-1]
3
4# Example usage
5print(is_palindrome("radar")) # Output:
True
6print(is_palindrome("hello")) # Output:
False
Q: Write a function to generate the first n
Fibonacci numbers.
python
Code:
def fibonacci(n):
2 fib_sequence = [0, 1]
3 for i in range(2, n):
4 fib_sequence.append(fib_sequence[-
1] + fib_sequence[-2])
5 return fib_sequence[:n]
6
7# Example usage
8print(fibonacci(10)) # Output: [0, 1, 1, 2,
3, 5, 8, 13, 21, 34]
Code:
def factorial(n):
2 if n == 0:
3 return 1
4 return n * factorial(n - 1)
5
6# Example usage
7print(factorial(5)) # Output: 120
Q: Write a function to check if a number
is prime.
Code:
def is_prime(n):
2 if n <= 1:
3 return False
4 for i in range(2, int(n**0.5) + 1):
5 if n % i == 0:
6 return False
7 return True
8
9# Example usage
10print(is_prime(11)) # Output: True
11print(is_prime(4)) # Output: False
Code:
def count_vowels(s):
2 vowels = 'aeiouAEIOU'
3 return sum(1 for char in s if char in
vowels)
4
5# Example usage
6print(count_vowels("hello world")) #
Output: 3
Code:
Code:
def find_max(lst):
2 return max(lst)
3
4# Example usage
5print(find_max([1, 2, 3, 4, 5])) #
Output: 5
def remove_duplicates(lst):
2 return list(set(lst))
3
4# Example usage
5print(remove_duplicates([1, 2, 2, 3, 4, 4,
5])) # Output: [1, 2, 3, 4, 5]
def sort_tuples(lst):
2 return sorted(lst, key=lambda x: x[1])
3
4# Example usage
5tuples_list = [(1, 3), (2, 1), (3, 2)]
6print(sort_tuples(tuples_list)) # Output:
[(2, 1), (3, 2), (1, 3)]
Code:
import matplotlib.pyplot as plt
2import numpy as np
3
4# Data
5class1 = np.random.normal(70, 10, 100)
6class2 = np.random.normal(80, 15, 100)
7class3 = np.random.normal(75, 20, 100)
8
9data = [class1, class2, class3]
10
11# Plot
12plt.boxplot(data, labels=['Class 1', 'Class 2',
'Class 3'])
13plt.title('Box Plot of Scores from Three Classes')
14plt.ylabel('Scores')
15plt.grid()
16plt.show()
Q: Create an area plot to visualize the cumulative
sales of a product over several months.
Code:
import matplotlib.pyplot as plt
2import numpy as np
3
4# Data
5months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
6sales = [100, 200, 300, 400, 500, 600]
7
8# Plot
9plt.fill_between(months, sales, color='skyblue',
alpha=0.4)
10plt.plot(months, sales, color='Slateblue',
alpha=0.6, linewidth=2)
11plt.title('Cumulative Sales Over Months')
12plt.xlabel('Months')
13plt.ylabel('Sales')
14plt.grid()
15plt.show()
Code: