OST Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

INDEX

S. No Name of the program


1. Explain Open-Source Software and List 10 names of OSS. Explain need of Open
Source technology.

2. Explain PHP? Variables and a simple program and datatypes.


3. Write a program to create student registration form.
4. Write a program to perform string operation in PHP.
5. Write a program to perform date time operation in PHP.
6. Write the steps to establish connection with XAMPP for MySQL.

7. Write the datatypes used in MySQL.

8. Write the query to perform the Create & Insert operation in MySQL.

9. Write the query to perform the Update & Delete operation in MySQL.

10. Write the query to perform the Selection operation in MySQL.

11. Write the query to perform the Sorting (Order By & Group By) in MySQL.

12. Write the query to perform Aggregate functions in MySQL.

13. Write the query to perform the DATE & TIME Operation in MySQL.

14. Write a program for add/remove element in tuple in python.

15. Write a program for add/remove elements in list in python.

16. Write a program for if-else conditional statement in Python.

17. Write a program to find the greater number among the three numbers in
python.

18. Write a program for print the table of given number in python.
19. Write a program for factorial of given number in python.
20. Write a program for Fibonacci series in python.
21. Write a program for File Handling in python.
Practical- 2
Object- Explain Open Source Software and List 10 names of OSS. Explain need of
opensource technology.

➢ Open Source Software-


The term "open source" refers to computer software or applications where the owners or copyright
holders enable the users or third parties to use, see, and edit the product's source code. The source code of
an open-source OS is publicly visible and editable. The usually operating systems such as Apple's iOS,
Microsoft's Windows, and Apple's Mac OS are closed operating systems. Open-Source Software is
licensed in such a way that it is permissible to produce as many copies as you want and to use them
wherever you like. It generally uses fewer resources than its commercial counterpart because it lacks any
code for licensing, promoting other products, authentication, attaching advertisements, etc. The open-
source operating system allows the use of code that is freely distributed and available to anyone and for
commercial purposes. Being an open-source application or program, the program source code of an open-
source OS is available. The user may modify or change those codes and develop new applications
according to the user requirement.

➢ List 10 names of OSS-


• Mozilla Firefox
• LibreOffice
• GIMP
• VLC Media Player
• Linux
• Blender
• GNU Compiler Collection
• Python
• PHP
• Shotcut

➢ Need Of Open Source Technology-


• The idea of open source stems from the technology community. From the earliest days of computers,
programmers and engineers developed new technologies through collaboration.
• For instance, a programmer in San Jose develops a new application, then another programmer in Singapore
studies the application and discovers ways to improve it. The knowledge is shared, and the entire
community benefits from the collective innovation.
• In many ways, the creation of the open source license was a direct response to proprietary manufacturing.
The not-for-profit Open Source Initiative (OSI) was founded in 1998.
• It administers open source licensing around the world, promotes open source development, facilitates
community and educational initiatives, and gives conferences.
Practical- 2
Object- Explain PHP? Variables and a simple program and datatypes.

➢ What is PHP-
PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the
server-side. PHP is well suited for web development. Therefore, it is used to develop web applications (an
application that executes on the server and generates the dynamic page.).
PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. PHP 7.4.0 is the latest
version of PHP, which was released on 28 November. Some important points need to be noticed about
PHP are as followed:
• PHP stands for Hypertext Pre-processor.
• PHP is an interpreted language, i.e., there is no need for compilation.
• PHP can be embedded into HTML.
• PHP is an object-oriented language.
• PHP is simple and easy to learn language.

➢ PHP Variables-
• In PHP, a variable is declared using a $ sign followed by the variable name.
• As PHP is a loosely typed language, so we do not need to declare the data types of the variables
automatically analyse the values and makes conversions to its correct datatype.
• After declaring a variable, it can be reused throughout the code.
• Assignment Operator (=) is used to assign the value to a variable.

Example-
$variablename=value;
<?php
$str="hello string";
$x=200;
$y=44.6;
echo "string is: $str <br/>";
echo "integer is: $x <br/>";
echo "float is: $y <br/>";
?>

Output:
➢ PHP Data Types-
PHP data types are used to hold different types of data or values.
• PHP Boolean- Booleans are the simplest data type works like switch. It holds only two values: TRUE
(1) or FALSE (0). It is often used with conditional statements. If the condition is correct, it returns
TRUEotherwise FALSE.
• PHP Integer-Integer means numeric data with a negative or positive sign. It holds only whole numbers,
i.e., numbers without fractional part or decimal points.
• PHP Float- A floating-point number is a number with a decimal point. Unlike integer, it can hold numbers
with a fractional or decimal point, including a negative or positive sign.
• PHP String- A string is a non-numeric data type. It holds letters or any alphabets, numbers, and even
special characters. String values must be enclosed either within single quotes or in double quotes. But
both are treated differently.
• PHP Array-An array is a compound data type. It can store multiple values of same data type in a single
variable.
• PHP object- Objects are the instances of user-defined classes that can store both values and functions.
They must be explicitly declared.
• PHP Null- Null is a special data type that has only one value: NULL. There is a convention of writing it
in capital letters as it is case sensitive.
Practical-3

Object- Write a program to create student registration form.

Code-
<html>
<head >
<title>registration</title>
</head>
<body bgcolor="sky blue">
<div>
<?php
if(isset($_POST['create']))
{
echo 'submitted';
}
?>
</div>
<div>
<form action "REGISTRATION.php" method="post">
<div class="container">
<center><h3>STUDENT REGISTRATION FORM</h3></center>
<label1 for="NAME"><b><h5>NAME</h5></b></label1>
<input type="text" name="NAME" required>
<label1 for="EMAIL"><b><h5>EMAIL</h5></b></label1>
<input type="EMAIL" name="EMAIL" required>
<label1 for="PASSWORD"><b><h5>PASSWORD</h5></b></label1>
<input type="PASSWORD" name="PASSWORD" required>
<input type="SUBMIT" name="SUBMIT">
</div>
</form>
</div>
</body>
</html>
Output-
Practical-4
Object- write a program to perform string operation in php.
Code-
<?php
$str="hello php";
$x=233;
$y=67.6;
echo "string is: $str <br/>";
echo "integer is: $x <br/>";
echo "float is: $y <br/>";
?>
Output-

Practical-5
Object- write a program to perform date time operation in php.
Code-
<?php
echo "Today's date in various formats:" . "\n";
echo date("d/m/Y") . "\n";
echo date("d-m-Y") . "\n";
echo date("d.m.Y") . "\n";
echo date("d.M.Y/D");
?>

Output-
Practical-6
Object- Write the steps to establish connection with XAMPP for MySQL.
Steps-
Step 1- firstly open XAMPP control panel and click on MYSQL start.

Step 2- now open Command Prompt and go to the C drive.


Step 3- go to the file explorer C:\xampp\mysql\bin and copy that path and paste on command prompt.
Step 4- now go to the mysql -u root and now we reach in a default DATABASE MariaDB[].
Step 5- now we can create our own database and can use it.
Practical-7
Object- Write the datatypes used in MySQL.
Data Types- A Data Type specifies a particular type of data, like integer, floating points, Boolean, etc. In
MySQL, each database table has many columns and contains specific data types for each column. In MySQL
there are three main data types: string, numeric, and date and time.

MySQL
Data
String Numeric

Date &
Time
1. String Types:-
Although the numeric and date types are fun, most data you'll store will be in a string format. This list describes
the common string datatypes in MySQL.
• Char(M) − A fixed-length string between 1 and 255 characters in length (for example CHAR(5)), right-padded
with spaces to the specified length when stored. Defining a length is not required, but the default is 1.
• Varchar(M) − A variable-length string between 1 and 255 characters in length. For example,
VARCHAR(25). You must define a length when creating a VARCHAR field.
• Blob Or Text − A field with a maximum length of 65535 characters. BLOBs are "Binary Large Objects" and
are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT
also hold large amounts of data. The difference between the two is that the sorts and comparisons on the stored
data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not
• Longblob Or Longtext − A BLOB or TEXT column with a maximum length of 4294967295 characters. You
do
not specify a length with LONGBLOB or LONGTEXT.
• Enum − An enumeration, which is a fancy term for list. When defining an ENUM, you are creating a list of
items from which the value must be selected (or it can be NULL). For example, if you wanted your field to
contain "A" or "B" or "C", you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or
NULL)could ever populate that field.

2. Numeric Data Type:-


MySQL uses all the standard ANSI SQL numeric data types, so if you're coming to MySQL from a different
database system, these definitions will look familiar to you.
The following list shows the common numeric data types and their descriptions −
• Int − A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -
2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a
width of up to 11 digits.
• Float(M,D) − A floating-point number that cannot be unsigned. You can define the display length (M) and
the number of decimals (D). This is not required and will default to 10,2, where 2 is the number of decimals
and 10 is the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT.
• Double(M,D) − A double precision floating-point number that cannot be unsigned. You can define the display
length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number
of decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE.
• Decimal(M,D) − An unpacked floating-point number that cannot be unsigned. In the unpacked decimals, each
decimal corresponds to one byte. Defining the display length (M) and the number of decimals (D) is required.
NUMERIC is a synonym for DECIMAL.

3. Date and Time Types:-


The MySQL date and time datatypes are as follows −
• Date − A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. For example, December 30th,
1973 would be stored as 1973-12-30.
• Datetime − A date and time combination in YYYY-MM-DD HH:MM:SS format, between 1000-01-01
00:00:00and 9999-12-31 23:59:59. For example, 3:30 in the afternoon on December 30th, 1973 would be
stored as 1973-12-30 15:30:00.
• Timestamp − A timestamp between midnight, January 1st, 1970 and sometime in 2037. This looks like the
previous DATETIME format, only without the hyphens between numbers; 3:30 in the afternoon on December
30th, 1973 would be stored as 19731230153000 ( YYYYMMDDHHMMSS ).
• Time − Stores the time in a HH:MM:SS format.
• Year(M) − Stores a year in a 2-digit or a 4-digit format. If the length is specified as 2 (for example YEAR(2)),
YEAR can be between 1970 to 2069 (70 to 69). If the length is specified as 4, then YEAR can be 1901 to 2155.
The default length is 4.
Practical-8
Object- Write the query to perform the Create & Insert operation in MySQL.
Create Table-
create database QueryCollection;
use QueryCollection;
Create table information(sno int, name varchar(10), subject varchar(20));
Output-

Insert Operation-
insert into information value(1,"neha","O.S.T."),
(2,"sakshi","O.S.T."),
(3,"rekha","O.S.T."),
(4,"renu","O.S.T.");
select*from information;

Output-
Practical-9
Object- Write the query to perform the Update & Delete operation in MySQL.
Update Operation-
update information set subject="OPEN SOURCE"
where(name="rekha");select*from information;
Output-

Delete Operation-
Delete from information where sno="4";
select*from information;
Output-
Practical-10
Object- Write the query to perform the Selection operation in MySQL.
Select name from information;
Output-

Select *from information;


Output-
Practical-11
Object-write the query to perform the Sorting (Order By & Group By) in
MySQL.
Order By-
select* from emp_info order by salary;
output-

Group By-
select* from emp_info group by emp_name;
output-
Practical-12
Object- Write the query to perform Aggregate functions in MySQL.
Sum()-
select sum(salary) "total_salary"from emp_info;

Avg()-
select avg(salary) "average_salary"from emp_info;

Max()-
select Max(salary) "max_salary"from emp_info;

Min()-
select Min(salary) "min_salary"from emp_info;

Count()-
select count(salary) "count of salary"from emp_info;
Practical-13
Object-Write the query to perform the DATE & TIME Operation in MySQL.
select CURRENT_TIMESTAMP AS "CURRENTTIMESTAMP";
Output-

Practical-14
Object-Write a program for add/remove element in tuple in python.
Add element-
Program-
thistuple = ("apple", "banana", "cherry")
y = list(thistuple)
y.append("orange")
thistuple = tuple(y)
print(thistuple)

output-

Remove element-
Program-
thistuple = ("apple", "banana", "cherry")
y = list(thistuple)
y.remove("apple")
thistuple = tuple(y)
print(thistuple)

output-
Practical-15
Object- Write a program for add/remove elements in list in python.
Program-
Add element-
thislist = ["apple", "banana", "cherry"]
thislist.append("orange")
print(thislist)
Output-

Program-
Remove element-
thislist = ["apple", "banana", "cherry"]
thislist.remove("banana")
print(thislist)

Practical-16
Object- Write a program for if-else conditional statement in Python.
Program-
a=2
b=4
if(a<b)
:
print("a is less then b")
else:
print("b is the less then a")

Output-
Practical-17
Object- Write a program to find the greater number among the three numbers in
python.
Program
-n1=3
n2=4
n3=6
if(n1>n2):
if(n1>n3)
:
print("n1 is greater number")
else:
print("n3 is greater number")
elif(n2>n3):
print("n2 is greater number")
else:
print("n3 is greater number")
Output-

Practical-18
Object- Write a program for print the table of given number in python.
Program-
list=[1,2,3,4,5,6,7,8,9,10]
n=2
for i in list:
table=n*i
print(table)
Output-
Practical-19
Object- Write a program for factorial of given number in python.
Program-
num=5
factorial=1
for i in range(1,num+1):
factorial=factorial*i
print("the factorial of",num,"is:",factorial)

Output-

Practical-20
Object- Write a program for Fibonacci series in
python.Program-
num=5
n1=0
n2=1
count=0
while(count<num):
n3=n1+n2
print(n3)
n1=n2
n2=n3
count+=1
Output-
Practical-21
Object- Write a program for File Handling in python.
Read the file-
f=open("welcome.txt",)
print(f.read())
Output-

Write/Create the file-


f=open("welcome.txt","a")
f.write("file have more content!")
f.close()
f=open("welcome.txt","r")
print(f.read())
Output-

Delete the file-


import os
if os.path.exists("welcome.txt"):
os.remove("welcome.txt")
print("delete successfully deleted")
else:
print("file doesnot exist")
Output-

You might also like