Sum of first 10 natural numbers.
Program:
Output:
1. Check if the number is prime or not.
Program:
Output:
2. Fibonacci series upto n terms.
Program:
Output:
3. Factorial of a number.
Program:
Output:
4. Print the squares of first 10 natural numbers.
Program:
Output:
5. Input termperature in celsius and convert it into farenheit.
Program:
Output:
6. Menu driven program to calculate area of circle,cuboid or cube.
Program:
Output:
7. Create a dictionary with 5 items and apply all methods learnt.
Program:
8. Perform linear search on a list.
Program:
Output:
9. Count the no. of occurences of an element.
Program:
Output:
10. Create a list with n elements and find the sum of the elements.
Program:
Output:
11. Input a string and count the number of vowels in it.
Program:
Output:
12. Input a string and apply all functions learnt.
Program:
Output:
13. Input a number and check if it is positive negative or zero.
Program:
Output:
14. 4 slicing questions.
Program:
Output:
15. Simple calculator with all arithmetic operators.
Program:
Output:
16. WAP to display even numbers from 10 to 20.
Program:
Output:
17. WAP to display prime no.s below 30.
Program:
Output:
18. WAP to filter even and odd numbers from a list.
Program:
Output:
19. WAP to display all numbers divisible by 13 and not by 3 between 100 and 500.
Program:
Output:
MYSQL
Based on the given table answer the queries given below:
1) Display the details of all the students.
SELECT*FROM students;
2) Display the names of students below age 22.
SELECT NAME FROM students where age<22;
3) Change bob’s grade to a and display it.
UPDATE students SET grade=’A’ where name=’Bob’;
4) Insert a new record.
INSERT INTO students VALUES(11,’Rose’,19,’B’);
5) Add a new column called city.
ALTER TABLE students ADD COLUMN(city char(30));
6) Delete Charlie’s record.
DELETE FROM students where name=’Charlie’;
7) What will be the output for : select * from students where grade=’B’;
8) What will be the output for: select id,name from students where age<25 order by age;
9) What will be the O/P for: select* from students where city is null;
10) What will be the output for: select*from students where id between 1 and 5;
2nd table:
1) Display products that are over 200aed.
Select product_name from store where price>200;
2) Display product_id of those products who have a quantity less than 25.
Select product_id from store where quantity<25;
3) Change the ‘price’ column to ‘unit_price’with the same size.
Alter table store RENAME column price unit_price decimal(8,2);
4) Write a query so that productname values displayed are unique and not duplicate.
Alter table store add primary key(product_id);
However, since there is already a primary key an error will be displayed as below:
5) Change the character size of product name to 100.
Alter table store MODIFY column product_name char(100);
6) Set the default value for city as ‘dubai’.
Alter table store add city char(67) default 'dubai';
7) O/P of desc store?
8) What will be the output for: INSERT INTO store values(105,’earbuds’,2000,35,’dubai’);
An error will be displayed in this manner.
9) What will be the output for: UPDATE store SET price=5000 where product_name=’Laptop’;
10) What will be the output for: SELECT* from store order by unit_price desc;
3rd table:
1) Display all the employees from the IT department.
Select * from employee where dep=’IT’;
2) Display the employee names who are born before the year 1990.
Select first_name from employee where dob<’1990-01-01’;
3) Modify the salary of employee number 1002 to 80000.00.
UPDATE employee SET salary=80000.00 where empid=1002;
4) Display the details of those employees with a salary above 70000 in descending order.
Select*from employee where salary>70000.00 order by salary desc;
5) Display the last names of the employees whose names begin with D.
Select last_name from employee where first_name like ‘D%’;
6) Display the details of those employees whose first names contain a and last names contain s.
Select*from employee where first_name like ‘%a%’ and last_name like ‘%s%’;
7) Increase the salary of employees working in the finance department by 5000.
UPDATE employee SET salary=salary+5000 where dep=’finance’;
8) O/P for: SELECT first_name, salary FROM employee WHERE dep = 'IT';
9) O/P for: SELECT DISTINCT YEAR(dob) from employee;
10) O/P for: SELECT * FROM employee WHERE last_name LIKE '%son';
4th table:
1) Display all the projects.
Select project_name from projects;
2) Display those projectids where the budget is more 70000.
Select project_id from projects where budget>70000;
3) Display the details of the projects starting after 2024.
Select*from projects where start_date>’2024-01-01’;
4) Display the projects managed by Jane.
Select *from projects where project_manager=’Jane Lead’;
5) Modify the budget of project a to 52500 aed.
UPDATE projects SET budget=52500.00 WHERE project_name=’project A’;
6) Delete those projects who ended before 2024-06-01.
DELETE from projects WHERE end_date<’2024-06-01’;
7) Display those project details whose names start with ‘project’.
Select*from projects where project_name like ‘project%’;
8) O/P for: SELECT project_name, start_date FROM projects WHERE department = 'HR';
9) O/P for: SELECT project_name, budget FROM projects WHERE budget BETWEEN 60000 AND
90000;
10) O/P for: SELECT * FROM projects WHERE end_date > '2024-07-01' AND project_manager =
'Sophia Lead';
5th table:
1) Display all the customers
Select*from customers;
2) Display details of customers whose name ends with Smith.
Select*from customers where last_name=’Smith’;
3) Display the customers with valid phone numbers.
Select phone_number from customers where phone_number IS NOT NULL.
4) Change the email for customer 13 to chrisl@gmail.com
UPDATE customers SET email=’chrisl@gmail.com’ WHERE customer_id=13;
5) Delete the records of those customers with no email registered.
DELETE from customers where email IS NULL;
6) Retrieve the details of those customers names beginning with J.
Select*from customers where first_name like ‘J%’;
7) Display the names of those customers who registered in 2022.
Select first_name,last_name from customers where year(registration_date)=2022;
8) O/P for: SELECT * FROM customers WHERE email IS NOT NULL OR phone_number IS
NOT NULL;
9) O/P for: SELECT * FROM customers ORDER BY registration_date DESC;
10) O/P for: SELECT * FROM customers WHERE registration_date < '2023-01-01' AND email
IS NOT NULL;
6th table:
1) Display all the books in the bookstore.
Select*from bookstore;
2) Display the books in the mystery genre.
Select title from bookstore where genre=’mystery’;
3) Retrieve those books under the price of 20 aed.
Select title from bookstore where price<20;
4) List those books published before the year 2010.
Select*from bookstore where publication_year<2010;
5) Display books that have content belonging to scifi.
Select book_id from bookstore where genre=’science fiction’;
6) Delete books that are out of stock.
DELETE from bookstore where stock_quantity=0;
7) Delete records of those books with no authors.
DELETE from bookstore where author IS NULL;
8) O/P for: SELECT title, author FROM bookstore WHERE genre = 'Classic';
9) O/P for: SELECT * FROM bookstore WHERE price BETWEEN 20.00 AND 30.00;
10) O/P for: SELECT * FROM bookstore WHERE publication_year > 2005 AND author IS
NULL;
7th table:
1) Display all the vehicles.
Select*from vehicles;
2) Display those cars that are electric.
Select*from vehicles where fuel_type=’electric’;
3) Retrieve the details of those vehicles priced below 30000 aed.
Select*from vehicles where price<30000;
4) Display cars manufactured after the year 2020.
Select brand from vehicles where year>2020;
5) Modify Toyota Camry’s colour to red.
UPDATE vehicles SET colour=’red’ WHERE brand=’Toyota’ and model=’Camry’;
6) Delte vehicles running on diesel.
DELETE from vehicles where fuel_type=’diesel’;
7) Find and display blue hybrid cars.
Select vehicle-id,brand,model from vehicles where colour=’blue’ and fuel_type=’hybrid’;
8) O/P for: SELECT distinct brand,model from vehicles;
9) O/P for: SELECT * FROM vehicles WHERE price BETWEEN 25000.00 AND 35000.00;
10) O/P for: SELECT * FROM vehicles WHERE model IN ('Sorento', 'Outback');
8th table:
1) Display all the movies in the order of their descending release years.
Select*from movies order by release_year desc;
2) Display all action movies after 2010.
Select title from movies where genre=’action’ and release_year>2010;
3) Retrieve movies directed by Christopher Nolan.
Select*from movies where director=’Christopher Nolan’;
4) Display movies with their ratings if they are rated above 8 points.
Select title,rating from movies where rating>8.0;
5) Display the various directors.
Select DISTINCT directors from movies;
6) Delete records of movies with no genres.
DELETE from movies where genre IS NULL;
7) Find and display movies with titles which have the word ‘love’ in it.
Select*from movies where title like ‘%love%’;
8) O/P for: select*from movies;
9) O/P for: SELECT * FROM movies WHERE release_year BETWEEN 2010 AND 2019 AND rating
> 7.5;
10) O/P for: Select DISTINCT genre from movies;
9th table:
1) Display all the countries in Asia.
Select country_name from countries where continent=’Asia’;
2) Display countries with population greater than 100M.
Select country_name from countries where population>100000000;
3) Display the capital of Brazil.
Select capital_city from countries where country_name=’Brazil’;
4) Which countries have English as their official language? Write a query to display it.
Select*from countries where official_language=’English’;
5) Display the different continents of the world.
Select DISTINCT continent from countries;
6) Add a column named GDP with the requirements needed.
ALTER table countries ADD column (GDP int);
7) Alter the column size of official lang to 100.
ALTER table countries MODIFY column official language char(100);
8) O/P for: SELECT capital_city, population FROM countries WHERE continent = 'Europe';
9) O/P for:SELECT country_name, gdp FROM countries WHERE gdp IS NULL;
10) O/P for: SELECT country_name, population FROM countries ORDER BY population DESC;
10th table:
1) Display the names and professions of the celebrities.
Select name,profession from celebrities;
2) Display the nationalities of celebrities who have won more than 10 awards.
Select nationality from celebrities where awards_won>10;
3) Display details of celebrities who are actors or singers.
Select*from celebrities where profession=’actor’ or profession=’singer’;
4) Allow the awards won column to accept null values.
ALTER table celebrities MODIFY column awards_won int null;
5) Display names of celebrities who have won around 5 to 20 awards.
Select name from celebrities where awards_won between 5 and 20;
6) List details of celebrities who have birthdays in the month of June.
Select*from celebrities where month(birth_date)=’June’;
7) Display the professions of celebrities whose names end with n.
Select profession from celebrities where name like ‘%n’;
8) O/P for: SELECT name, birth_date, profession FROM celebrities WHERE birth_date < '1990-01-
01';
9) O/P for:SELECT name, nationality FROM celebrities WHERE nationality LIKE 'A%' OR nationality
LIKE 'S%';
10) O/P for: SELECT name, awards_won FROM celebrities WHERE awards_won IS NULL;