Sunteți pe pagina 1din 8

MEPCO SCHLENK ENGINEERING COLLEGE

FREE OPEN SOURCE SOFTWARE ASSIGNMENT-II


BY,
D.Angel Jensi Prabha,
III-IT,
(17BIT002).

1. Write MySQL queries for the following schema:


Movie(Id,title,budget,hero,genre)

A) Create a above table Movie

Answer:
create table Movie(id integer,title varchar(20),budget integer,hero
varchar(20),genre varchar(20));

Query OK, 0 rows affected (0.29 sec)

B) Insert values into the above created table.

Answer:
insert into Movie values(1,"Pollathavan",122200000,"Rajini",23);
Query OK, 1 row affected (0.07 sec)

insert into Movie values(2,"Movie2",122200000,"Kamal",23);

Query OK, 1 row affected (0.04 sec)

insert into Movie values(101,"Movie2",1200,"kamal",45);

Query OK, 1 row affected (0.04 sec)

C) Select title,genre,budgetof the movie acted by hero ‘Rajini’or‘kamal’.

Answer:
select title,genre,budget fromMoviewhere hero like "Rajini" or
"Kamal" ;

+-------------+-------+-----------+
| title | genre | budget |
+-------------+-------+-----------+
| Pollathavan | 23 | 122200000 |
+-------------+-------+-----------+

1 row in set, 1 warning (0.00 sec)

D) Delete the movie entry from a table by giving the hero.


Answer:
delete title from Movie where hero=”kamal”;

Query OK, 1 row affected (0.06 sec)

E) Modify the budget of movie id 101 as 120000.

Answer:
update Movie set budget=120000 where id=101;

Query OK, 1 row affected (0.08 sec)

Rows matched: 1 Changed: 1 Warnings: 0

F)Display the average, maximum and minimum salary of each hero

Answer:
select avg(budget) from Movie group by(hero);
+----------------+
| avg(budget) |
+----------------+
| 61160000.0000 |
| 122200000.0000 |
+----------------+

2 rows in set (0.00 sec)


select min(budget) from Movie group by(hero) ;

+-------------+
| min(budget) |
+-------------+
| 120000 |
| 122200000 |
+-------------+

2 rows in set (0.00 sec)

select max(budget) from Movie group by(hero);


+-------------+
| max(budget) |
+-------------+
| 122200000 |
| 122200000 |
+-------------+
2 rows in set (0.00 sec)

Python and Perl

1.Write a python function to find the max, minimum elements in a list

(Or)
2.Write a perl subroutine to find the factorial of given number

Answer:
def min(l):
a=l[0]
for i in l:
if i <a:
a=i
return a
def max(l):
b=l[0]
for i in l:
if i >b:
b=i
return b
def min_max(l):
x=min(l)
y=max(l)
return x,y
min,max=min_mac([1,2,50,-2,10,5])
print(min)
print(max)

Output:

-2
50

File Handling:

1.Write a python program to copy the content of one file to another file.

(Or)

2.Write a Perl program to copy the content of one file to another file.

Answer:

my $file1 = "file1.txt";

open(FHSRC, $file1)
open(FHDES, '>>file2.txt')
while($line = <FHSRC>)
{
print FHDES $line."\n";

close(FHSRC);
close(FHDES);
OUTPUT:

file1.txt
Hai
how are you
file2.txt
Hai
how are you

S-ar putea să vă placă și