Professional Documents
Culture Documents
ECM-II-II-204 pages (1) (1)
ECM-II-II-204 pages (1) (1)
LAB MANUALS
For
IT WORKSHOP & PYTHON
PROGRAMMING
(From Page No.1 to 71 )
&
DATABASE MANAGEMENT SYSTEMS
(From Page No. 72 to 128 )
&
ANALOG & PULSE CIRCUITS
(From Page No. 129 to End)
FOR
B. Tech. II Year - II Semester
ECM Branch
Course Objectives
Students will try to learn
Basics of Python programming, Decision Making and Functions in Python, Object Oriented Programming
using Python.
To introduce to a personal computer and its basic peripherals, the process of assembling a personal
computer, installation of system software like MS Windows, Linux and the required device drivers.
Course Outcomes
Students will be able to
1. Apply knowledge for computer assembling and software installation and ability to solve the trouble shoot-
ing problems.
2. Apply the tools for preparation of PPT, Documentation and budget sheet etc.
3. Install and run the Python interpreter, Create and execute Python programs.
4. Apply the best features of mathematics, engineering and natural sciences to program real life problems.
5. Describe the Numbers, Math functions, Strings, List, Tuples and Dictionaries in Python, Express different
Decision Making statements and Functions, Interpret Object oriented programming in Python.
6. Understand and summarize different File handling operations, explain how to design GUI Applications in
Python.
IT Workshop
Week 1:
Introduction to Computer: Identify the peripherals of a computer, components/peripherals in a
CPU & its functions. Introduction to the types of Operating System, Assembling and
disassembling demonstration.
Week 2:
Install computer with dual boot operating system (Windows, Linux with PowerPoint
presentation). Comparison of types of OS in different platform
Week3:
Introduction to S/W's, difference b/w hardware and software. Introduction to MS-Office and its
importance.
Ms Word
Ms Power Point Presentation
Week4:
Introduction to Excel
Features: Accessing, Overview at toolbars, saving excel files, Gridlines, Format cells,
Summation, Auto fill, formatting text.
Formula in excel – Average, Standard Deviation, Charts, Roaming & Inserting worksheets,
Hyper linking, count function, lookup / Vlookup, sorting, Conditional formatting.
1|Page
IT Workshop Lab
Week 1:
Identify the peripherals of a computer, components in a CPU and its functions. Draw the
block diagram of the CPU along with the configuration of each peripheral and submit to
your instructor
AIM: To identify the peripherals of a computer.
1. The Mother Board
2. CPU (Processor)
2|Page
4. Cabinet
3|Page
7. HDD (Hard Disk Drive)
9. CD-ROM Drive
4|Page
10. CD Writer
11 Different Screws
5|Page
12. AGP (Accelerated Graphics Port) Card
6|Page
THE MOTHER BOARD
Socket 478
DDR RAM
SD RAM
Slots
Slots
Bridge
North
ATX Power
Connector
Floppy Drive
AGP Slot Connector
South Primary
Bridge Secondary
BIO
S
PCI Slots
CMOS Battery
1. Setting the cabinet ready.
2. Preparing to fit the components.
3. Fitting the mother board.
4. Fitting the RAM, processor and cooler.
5. Installing PCI cards.
6. Fitting the hard disk and floppy drive.
7. Installing the CD ROM drives.
8. Connecting the ribbon cables.
9. Powering the drives and mother board.
10. Connecting the cables for the case front panel.
11. Final check.
7|Page
Getting the Cabinet ready:-
1. Check how to open the cabinet and determine where to fix the components.
2. Determine if the case has the appropriate risers installed.
ATX Connectors:
1. PS, Mouse.
2. Key board.
3. USB.
4. Parallel ( Prints )
8|Page
5. Serial COM1.
6. Serial COM 2.
7. Joystick.
8. Sound.
9|Page
1. SD, SPK or SPEAK: The loud speakers o/p. it has 4 pins.
2. RS, RE, RS or RESET: Connect the two pin Reset cable here.
3. PWR, PW, PWSW, PS or power SW: Power switch, the pc’s on (switch, the plug is
two pin ).
4. PWLED, PWRLED or Power LED: The light emitting diode on the front panel of the
case illuminates when the computer is switched on. It’s a 2-pin cable.
5. HD, HDD, and LED: These two pins connect to the cable for the hard disk activity
LED.
Final Check:-
1. Mother board jumper configurations are the settings for the processor operator.
2. Drive jumper settings, master/ slave correct?
3. Are the processor, RAM modules and plug in cards finally seated in there sockets?
4. Did you plug all the cables in? Do they all fit really?
5. Have you frightened all the screws in plug- in cards or fitted the clips?
6. Are the drive secure?
7. Have u connected the power cables to all driver?
10 | P a g e
Week 2:
AIM: To install Windows XP
PROCEDURE:
1. Keep on press the delete button and go to advanced BIOS feature. [BIOS- Basic Input
Output System]
2. And go to boot sequence. Select first boot drivers. CD ROM and press F10 to save
the bios feature. Yes and then enter. Press any key to boot from CD. Press enter to
setup windows XP.
F8 = To agree the license.
3. Press ESC to don’t repair the windows XP setup.
4. Press ‘p’ to delete the previous partitions. Then press enter.
5. Press ‘L’ to delete the partition.
6. Press ‘C’ to create the partition in the un partition space.
7. Press enter to setup windows XP on the selected items.
PROCEDURE:
1. Language Selection
Using your mouse select the language you would prefer to use for the installation
Click next to continue.
11 | P a g e
Using your mouse select the correct layout type for the keyboard you would prefer to use
for the installation and as the system default.
Once you have made the selection click next to continue.
3. Mouse Configuration:
If you have a PS/2 ,USB or Bus mouse you do not need to pick a port and device. If you
have a serial mouse, you should choose the correct port and device that your serial mouse
is on.
The Emulate 3 buttons checkbox allows you to use a two-button mouse as if it had
three buttons. If you select this check box you can emulate a third “middle” button by
pressing both mouse buttons simultaneously.
4. Installation Type:
Choose the type of installation you would like to perform.
Your options are Personal desktop, Workstation, Server, Custom and upgrade
7. Adding Partitions:
To add a new partition select new button, a dialogue box appears.
12 | P a g e
Select the options and click ok
8. Boot Loader Configuration:
Boot loader is the first software program that runs when a computer starts.
The installation program provides two boot loaders GRUB ( GR and Unified Boot
Loader) which is the default and LILO
If you do not want GRUB as your boot loader click Change Boot Loader.
You can then choose to install LILO or choose not to install boot loader at all by clicking
Do not install boot loader on the change boot loader button.
Network devices are automatically detected and displayed in Network Devices list,
Select a network device and click Edit
Here you can configure IP address and net mask of the device.
9. Firewall configuration:
Offers firewall protection for enhanced protection.
A properly configured firewall can greatly increase the security of the system.
Viva Questions:
1) NTFS stands for_____________?
2) What is the use of product key in the installation process of software?
3) How many characters does a product key contain fro windows XP?
4) Describe different kinds of Microsoft Operating systems?
5) What are the pre-arrangements for installing the windows OS?
6) Give the advantages of Linux over other OS?
7) What do you mean by open source OS?
8) What are the commands used to make disk partitioning manually in Linux OS?
9) What do you mean by dual boot systems?
10) Which type of file systems are required to install hard disk at the time of installation of
Linux OS?
13 | P a g e
Week3:
Software
It refers to the programs to run the computer. Software is a group of instructions that tell the
hardware what to do. These instructions are also called ‘programs’.
Ex: Ms Outlook Express, ASP, VB, Java, MS Office etc.
Ms Word
INTRODUCTION TO MS-WORD
Let us consider an office scene. Many letters are typed in the office. The officer dictates a letter.
The typist first types a draft copy of the letter. The officer goes through it to check mistakes
regarding spelling errors, missing words, etc. and suggests corrections. The typist changes the
letter as suggested by the officer. This is a simple example of word processing.
There are many software packages to do the job of word processing. Some of them work in DOS
environment. Example are WordStar, Word Perfect and Professional Write. But in these days
working in WINDOWS is becoming more and more popular. So let us consider software for
word processing which works in WINDOWS. Our choice is MS-WORD because it is the most
popular software in these days.
MS-WORD is a part of the bigger package called MS OFFICE, which can do much more than
word processing. In fact when you open up MS OFFICE you will find four main components in
it. They are MS-WORD (for word processing), MS EXCEL (for spreadsheet), MS ACCESS (for
database management) and MS POWERPOINT (for presentation purposes). However, we will
limit ourselves to MS-WORD only in this lesson.
Objectives
After going through this lesson you should be in a position to
start the MS-WORD package
be familiar with the MS-WORD screen
advantages and Features of Word Processing
some common Word Processing Packages
14 | P a g e
how to invoke Ms-Word
learn the capabilities of Ms-Word
What is Word-Processing?
Word Processor is a Software package that enables you to create, edit, print and save documents
for future retrieval and reference. Creating a document involves typing by using a keyboard and
saving it. Editing a document involves correcting the spelling mistakes, if any, deleting or
moving words sentences or paragraphs.
15 | P a g e
v. Text can be formatted in columnar style as we see in the newspaper. Text boxes can be
made.
vi. Tables can be made and included in the text.
vii. Word also allows the user to mix the graphical pictures with the text. Graphical pictures
can either be created in word itself or can be imported from outside like from Clip Art
Gallery.
viii. Word also provides the mail-merge facility.
ix. Word also has the facility of macros. Macros can be either attached to some function/spe-
cial keys or to a tool bar or to a menu.
x. It also provides online help of any option.
16 | P a g e
The Scroll Bar helps you scroll the content or body of document. You can do so by
moving the elevator button along the scroll bar, or by click in on the buttons with the
arrow marked on them to move up and down and left and right of a page.
f. Workspace
The Workspace is the area in the document window were you enter/type the text of your
document.
g. Main Menu
The Word main menu is displayed at the top of the screen as shown in the Fig. 9.1. The
main menu further displays a sub menu. Some of the options are highlighted options and
some of them appear as faded options. At any time, only highlighted options can be
executed, faded options are not applicable. Infect if the option is faded you will not be
able to choose it. You may not that any option faded under present situation may become
highlighted under different situations.
Starting MS Word
Click on Start -> Programs -> Microsoft Word
Major operations of MS Word
1. Create, open, save and print the documents.
2. Typing, editing, cut, copy, paste and justify the text.
3. Spell check & grammatical errors.
4. Format the paragraphs.
5. Create & manipulate tables.
6. Using Spell-checker.
7. Page setup, paper size, margin, header, footer, page numbering.
8. Word count.
Introduction:
Microsoft PowerPoint is a software product used to perform computer-based presentations.
There are various circumstances in which a presentation is made: teaching a class, introducing a
product to sell, explaining an organizational structure, etc.
There are two main kinds of presentations you can deliver: before an audience or not. The prepa-
ration and the actual delivery of each are quite different. Before getting into the details of each,
we will first take a look at the software and analyze what it has to offer.
Starting Microsoft PowerPoint
To use Microsoft PowerPoint, you must first open it:
One way you can open Microsoft PowerPoint by clicking Start -> (All) Programs ->
Microsoft Office Microsoft Office PowerPoint.
Sometimes somebody may send you a Microsoft PowerPoint presentation as an E-Mail
attachment, a file on a floppy disk, or a file on the network, etc. The file is usually repre -
sented by a Microsoft PowerPoint icon. You can double-click the icon to launch
Microsoft PowerPoint and immediately open the presentation.
17 | P a g e
You can open Microsoft PowerPoint using a shortcut. If you happen to use the software
on a regular basis, you can create a shortcut on your desktop or on the Quick Launch
area. Many users also take advantage of the Microsoft Office Shortcut Bar. Sometimes,
the icon you need will not be there; in that case you should insert it manually.
If you are working on a network of related computers, a presentation may be located in
another computer. Once you locate the computer or the folder on the network and you see
the Microsoft PowerPoint icon, you can double-click it. This would open the application
and the presentation. The network administrator can also create a link or shortcut to the
drive that is hosting the presentation. You can then click or double-click this link or
shortcut to open the presentation and, as a result, launch Microsoft PowerPoint.
18 | P a g e
Figure 11.5 You can forgo the AutoContent Wizard and templates and add slides that fit any lay-
out.
When you finish with a slide and you are ready to add the next one, click the New Slide toolbar
button and PowerPoint adds a blank slide to your presentation and presents the Slide Layout task
pane once more. A presentation contains one or more slides, so you need to click the New Slide
button every time you are ready to add the next slide to your presentation.
You can change the template design at any point while you're developing your presentation. To
do so, just click the toolbar's Design button and the templates appear in the Slide Design task
pane. When you select a template, PowerPoint converts your entire presentation to that tem-
plate's format. Each slide's background image and standard text such as headings and footers
then take on a uniform appearance. If you click another template, PowerPoint converts the entire
presentation once again to that new template. You can experiment with different templates to see
which, if any, match the tone of presentation you want to achieve.
The instructions on the template's generated slide, as shown in Figure 11.6, indicate what to do
next
These preset areas on each slide (placeholders) are designed to accept various kinds of data and
make entering information on slides a snap. For example, you can click in a text placeholder and
then type your text. In most cases, you edit the text, possibly change colors, and perhaps add a
graphic image to the slide. Placeholders help you more easily do this.
Figure 11.6 The template's placeholders provide instructions you follow to create a unique slide.
After you add the presentation's final slide, you can save your presentation. You can save the
presentation in PowerPoint format or in HTML for embedding into Web pages. Even if your pre-
sentation has video and other multimedia content, you can save the presentation as a Web page
for viewing from a browser.
You can save a presentation in much the same way as you save a file in Word or Excel. Choose
File, Save As and then specify a name for your presentation. PowerPoint automatically adds the
filename extension .ppt to your presentation's file.
Note
As you can see, if you start out designing your own slides without the use of a template, you can,
at any time later, apply one of the template styles to the slide. Therefore, if you don't like what
you generate from scratch, you can redesign the slide or entire presentation without re-entering
19 | P a g e
the slide's text. If you save a presentation as a template file, you can use that presentation's for-
mat for subsequent presentations.
Note
Without a template to get you started, presentations require that you manually create every slide
element, including the text, titles, and body. Most slides have a title and text, and many have a
graphic image. Why not let the AutoContent Wizard or the templates start things off right? The
predefined slides work for so many purposes. Resist the temptation to create your slides from
scratch until you acquaint yourself with the predefined slides. In most cases, the AutoContent
Wizard and templates provide exactly what your presentation needs.
AutoContent Wizard
In this method, user can create a presentation on suggested content and designs.
information according to their own.
Blank Presentation
It creates a new, blank presentation using the default settings for text and colors.
Starting MS PowerPoint
Click on Start -> Programs -> Microsoft PowerPoint
Major operations of MS PowerPoint
1. Create, open, save the presentation.
2. Add new slide(s) to the existing presentation.
3. View the presentation.
4. Start slide show.
5. Delete a slide.
6. Change the formatting.
7. Apply animation.
Week 4:
MS EXCEL (Microsoft Excel)
Microsoft Excel is allows user to create professional spreadsheets and charts. It performs
numerous functions and formulas to assist users in their projects.
A spreadsheet is a simple worksheet comprising of rows and columns, which allows storage of
data in the format of rows and columns.
20 | P a g e
With Microsoft Excel 2000, user can create detailed spreadsheets for viewing and collaboration.
User can create customized formulas for data and analyze it with the easy to construct charts.
Starting MS Excel
Overview of toolbars:
21 | P a g e
22 | P a g e
23 | P a g e
Selecting cell ranges
24 | P a g e
Saving excel files:
Grid lines:
Gridlines are the faint lines that appear around cells in Excel 2007. They are used to distinguish
cells on the worksheet.
25 | P a g e
Format cells:
A style in Excel 2007 is a combination of formatting options that is named and saved as part of
your current spreadsheet file. The new style can then quickly be applied to data and cells in the
spreadsheet.
26 | P a g e
4. Click on the new style name at the top of the gallery.
5. The style's formatting is immediately applied to the selected cells.
This will automatically color the items based on the range they are in…
Summation:
Probably the most popular function in any spreadsheet is the SUM function. The Sum function
takes all of the values in each of the specified cells and totals their values. The syntax is:
27 | P a g e
=SUM(first value, second value, etc)
In the first and second spots you can enter any of the following (constant, cell, range of cells).
Blank cells will return a value of zero to be added to the total.
Text cells cannot be added to a number and will produce an error.
A
Let's use the table here for the discussion that follows: 1 25
We will look at several different specific examples that show how 2 50
the typical function can be used! Notice that in A4 there is a
TEXT entry. This has NO numeric value and can not be included 3 75
in a total. 4 test
5
Auto fill:
When you fill in data based on adjacent cells by dragging the fill handle in Microsoft Excel, the
Auto Fill Options button is displayed just below and to the right of your filled selection. When
you click the Auto Fill Options button, a list of options appears that allows you to choose to fill
the cells with text or data, and whether or not to include the format of the initial selection or to
copy only the format.
The Auto Fill Options button is also displayed after you select the AutoFill option in the Series
dialog box. To show the Series dialog box, use one of the following procedures, as appropriate
for the version of Excel that you are running:
In Microsoft Office Excel 2007 and Excel 2010, click the Home tab, and then click Fill
in the Editing group.
28 | P a g e
In Microsoft Office Excel and in earlier versions of Excel, point to Fill on the Edit menu,
and then click Series.
The options that are available depend on the type of content in the cells (text or numbers) and on
the format of the data. You can use the Series command to find the AutoFill option and other
options.
Fill down:
Often we have several cells that need the same formula (in relationship) to the location it is to be
typed into. There is a short cut that is called Fill Down. There are a number of ways to perform
this operation. One of the ways is to
1. select the cell that has the original formula
2. hold the shift key down and click on the last cell (in the series that needs the formula)
3. under the edit menu go down to fill and over to down
A B C
Cells information is copied from its relative position. In other words in the
1 5 3 =A1+B1 original cell (C1) the equation was (A1+B1). When we paste the function
2 8 2 fill down it will look to the two cells to the left. So the equation pasted into (C2)
3 4 6 fill down would be (A2+B2). And the equation pasted into (C3) would be (A3+B3).
And the equation pasted into (C4) would be(A4+B4).
4 3 8 fill down
Fill right:
We can also fill right. We must select the original cell (and the cells to the right) and select from
the Edit menu -- Fill and Right.
A B C
1 =A2+$B$3 =B2+$B$3 =C2+$B$3 If we were to fill right from A1 to C1 we would get the
formulas displayed to the left. Notice that the second
2 6 2 5
part of the equation is FIXED or (ABSOLUTE
3 7 10 4 REFERENCE so always references B3 which is 10).
4 9 8 7
Formatting text:
We can use most of the tricks in our word processor to do the formatting of text. We can use :
bold face, italics, underline, change the color, align (left, right, center), font size, font, etc.
We need to select the cell (or group of cells) that we wish to change the formatting and then go
from the FORMAT menu -- down to CELLS -- click on FONT. Here is a picture of what you
will see there. Notice that you can choose to change the alignment as well as several other
options.
29 | P a g e
Formula in excel:
Excel Formulas
A formula is nothing more than an equation that you write up. In Excel a typical formula might
contain cells, constants, and even functions. Here is an example Excel formula that we have la-
beled for your understanding.
Advertise on Tizag.com
=B3 * 5 / SUM(B4:B7)
cell(s): B3 and the range of cells from B4:B7
constant(s): 5
function(s): SUM()
There are many functions built into many spreadsheets. One of the first ones that we are going to
discuss is the Average function. The average function finds the average of the specified data.
(Simplifies adding all of the indicated cells together and dividing by the total number of cells.)
The syntax is as follows.
=Average (first value, second value, etc.)
Text fields and blank entries are not included in the calculations of the Average Function.
A
1 25
Let's use the table here for the discussion that follows: 2 50
We will look at several different specific examples that show how
the average function can be used! 3 75
4 100
5
30 | P a g e
=average (A1:A4,
A1, A2, A3, A4 and 300 110
300)
=average (A1:A5) A1, A2, A3, A4, A5 62.5
=average (A1:A2,
A1, A2, A4 58.33
A4)
3. Press Enter and notice how cell A1 changes from your formula to the result!
This may seem simple, but there are a some very important things you should get out of this ex -
ample. When you start off a cell entry with the equal sign "=" you are telling Excel that you want
it to evaluate the following formula.
In our case we had a simple "1+1" we wanted Excel to solve for us. You can do this for addition,
subtraction, multiplication, division and any other operation you can think of.
Remember, if you do not start your entry with the equal sign, then Excel will not evaluate the
cell!
Using Cells to Create Dynamic Formulas
The most powerful aspect of Excel is not the simple calculator abilities we describes in our first
formula example, but rather the ability to take values from cells to be used in your formulas.
Let's set up a basic sales spreadsheet to help explain this topic.
1. In cells A1-D4 enter the following information:
31 | P a g e
Notice: that cell D2 and D3 are blank, but should contain the amount of money from sell-
ing 150 candy items and 3 vegetables. By referencing the Quantity and Price cells we will
be able to do this! Let's begin with Candy.
2. Note:It is very important to follow these steps exactly without interruptions! Select cell
D2, candy's "revenue", and type the equal sign "=" to begin your formula.
3. Left-click on cell B2, Candy's Quantity and notice your formula is now "=B2"
32 | P a g e
6. If your formula looks like ours then press Enter, otherwise you can manually enter the
formula "=B2*C2". However, we really think it is easier and preferred to click on cells to
reference them, instead of entering that information manually.
7. After you pressed Enter your Candy Revenue cell should be functioning properly and
contain the value 75.
8. Using your newly gained knowledge please complete Vegetable's Revenue by repeating
steps 2-7 for Vegetable
9. Your spreadsheet should now look like this:
10. Cheatsheet: If you are having trouble creating the formula for Vegetable's Revenue it is
"=B3*C3"
Advanced Excel Formulas: Using Formulas in Formulas
Now that we have created separate revenues for both Candy and Vegetable it would be nice to
somehow combine these two values to get the Total Revenue. Although both Vegetable Revenue
and Candy Revenue contain formulas, we can still use these cells as we have been doing and add
them together to get our total.
1. Select cell D5 (directly below "Total")
2. Type the equal sign "="
3. Left-click cell D2
4. Type the plus sign "+"
33 | P a g e
5. Left-click cell D3. Cell D5 should now contain this formula "=D2+D3":
Creating Charts
In Microsoft Excel, you can represent numbers in a chart. On the Insert tab, you can choose from
a variety of chart types, including column, line, pie, bar, area, and scatter. The basic procedure
for creating a chart is the same no matter what type of chart you choose. As you change your
data, your chart will automatically update.
You select a chart type by choosing an option from the Insert tab's Chart group. After you choose
a chart type, such as column, line, or bar, you choose a chart sub-type. For example, after you
choose Column Chart, you can choose to have your chart represented as a two-dimensional chart,
a three-dimensional chart, a cylinder chart, a cone chart, or a pyramid chart. There are further
sub-types within each of these categories. As you roll your mouse pointer over each option, Ex-
cel supplies a brief description of each chart sub
Create a Chart
34 | P a g e
To create the column chart shown above, start by creating the worksheet below exactly as
shown.
After you have created the worksheet, you are ready to create your chart.
35 | P a g e
Create a Column Chart
1. Select cells A3 to D6. You must select all the cells containing the data you want in your
chart. You should also include the data labels.
2. Choose the Insert tab.
3. Click the Column button in the Charts group. A list of column chart sub-types types ap-
pears.
4. Click the Clustered Column chart sub-type. Excel creates a Clustered Column chart and
the Chart Tools context tabs appear.
36 | P a g e
Apply a Chart Layout
Add Labels
When you apply a layout, Excel may create areas where you can insert labels. You use labels to
give your chart a title or to label your axes. When you applied layout 5, Excel created label areas
for a title and for the vertical axis.
Add labels
Before After
1. Select Chart Title. Click on Chart Title and then place your cursor before the C in Chart
and hold down the Shift key while you use the right arrow key to highlight the words
Chart Title.
2. Type Toy Sales. Excel adds your title.
3. Select Axis Title. Click on Axis Title. Place your cursor before the A in Axis. Hold down
the Shift key while you use the right arrow key to highlight the words Axis Title.
37 | P a g e
4. Type Sales. Excel labels the axis.
5. Click anywhere on the chart to end your entry.
Switch Data
If you want to change what displays in your chart, you can switch from row data to column data
and vice versa.
Switch Data
Before After
38 | P a g e
1. Click your chart. The Chart Tools become available.
2. Choose the Design tab.
3. Click the More buttons in the Chart Styles group. The chart styles appear.
39 | P a g e
1. Use the handles to adjust the size of your chart.
2. Click an unused portion of the chart and drag to position the chart beside the data.
40 | P a g e
4. Click the New Sheet radio button.
5. Type Toy Sales to name the chart sheet. Excel creates a chart sheet named Toy Sales and
places your chart on it.
41 | P a g e
Hyper linking:
In Excel, the Hyperlink function creates a shortcut to a file or Internet address.
The syntax for the Hyperlink function is:
Hyperlink ( link, display_name )
link is a path to the file or the URL to the Internet address.
display_name is optional. It is the value that appears in the cell. If this parameter is omitted, then
the link will appear in the cell.
For example:
In our first example, we're using the Hyperlink function to reference a file called "Doc1.doc" that
can be found in the c:\test\ directory. The following formula has been entered in cell A1:
=Hyperlink("c:\test\Doc1.doc","Test document")
42 | P a g e
When a user clicks on cell A1, the Word document called "Doc1.doc" will automatically open.
In our second example, we're using the Hyperlink function to reference an Internet address. The
following formula has been entered in cell A1:
=Hyperlink("http://www.techonthenet.com","Tech on the Net")
When a user clicks on cell A1, the default web browser will open to the site called
www.techonthenet.com.
Count function:
Excel's COUNT function is one of a group of Count Functions that can be used when you need
to total the number of cells in a selected range.
The COUNT function's job is to only add up the cells in a selected range that contain numbers. It
ignores empty cells or those contain text. If a number is later added to an empty cell the function
will be automatically updated to include this new data.
Be aware that dates, times, functions, and formulas are stored as numbers in Excel. The COUNT
function will, therefore, include any cells containing these types of data in the total.
The syntax for the COUNT function is:
=COUNT( Range )
Range - the group of cells the function is to count.
Example Using Excel 2007's COUNT Function:
Note: For help with this example, see the image above.
1. Enter the following data into cells D1 to D4: 11, twelve, 13, 14.
2. Enter the following data into cell D6: 16.
3. Note that we have intentionally left cell D5 blank.
4. Click on cell E1 - the location where the results will be displayed.
5. Click on the Formulas tab.
6. Choose More Functions > Statistical from the ribbon to open the function drop down
list.
7. Click on COUNT in the list to bring up that function's dialog box.
8. Drag select cells D1 to D6 on the spreadsheet to enter the range into the dialog box.
43 | P a g e
9. Click OK.
10. The answer 4 should appear in cell E1 since only four of the six cells in the range contain
numbers.
11. Cell D2, which contains text, and cell D5, which is blank, are ignored by the COUNT
function.
12. When you click on cell E1 the complete function =COUNT( D1 : D6 ) appears in the
formula bar above the worksheet.
Lookup/Vlookup :
Lookup:
The Lookup Value
The lookup value is located in the first column of the table of data. After specifying a subject in
the first column, VLOOKUP will then allow you to search for specific information located in the
same row as the subject.
The lookup value can be a text string, a logical value (TRUE or FALSE only), a number, or a
cell reference to a value.
It is a good idea to use an absolute cell reference for the lookup value.
If you don’t use an absolute reference and you copy the VLOOKUP function to other cells, there
is a good chance you will get error messages in the cells the function is copied to.
Vlookup:
Excel VLOOKUP Function
44 | P a g e
Excel's VLOOKUP function, which stands for vertical lookup, can help you find specific
information in large data tables such as an inventory list of parts or a large membership contact
list.
Sorting:
Excel's sort feature is a quick and easy way to sort data in a spreadsheet. The options for sorting
your data include:
Sort in ascending order - A to Z alphabetically or smallest to largest for number data.
Sort in descending order - Z to A alphabetically or largest to smallest for number data.
Custom sort - includes sorting by the cell background color or the font color of the data.
45 | P a g e
6. The data in cells A1 to A6 should now be in this order:
5, 20, 25, 30, 40, 60.
Note: Excel knows the difference between text and number data and adjust the options in the
drop down list accordingly. For example, if cells A1 to A6 contained text - such as words or
letters of the alphabet - instead of numbers the options in the Sort & Filter drop down list would
change to Sort A to Z instead of Sort smallest to largest .
Also Note: If you have multiple columns of related data and you wish to perform a simple sort
on one of those columns - such as sorting an address list by the person's last name - remember to
select all columns of related data before carrying out the sort in order to keep your data together.
Conditional formatting:
You can also create your own rule to color only cells that fit within a certain range, or greater
than a certain number.
This rule will only color cells greater than a certain amount, with the color you specify.
46 | P a g e
This can be very useful, and you should note that you can apply a second rule to the same range.
For instance, I added a second rule that colored items larger than 2000 with green instead of red.
47 | P a g e
Python Programming Lab
Week -1:
1. Use a web browser to go to the Python website http://python.org. This page contains
information about Python and links to Python-related pages, and it gives you the ability
to search the Python documentation.
2. Start the Python interpreter and type help() to start the online help utility.
3. Start Python interpreter and use it as Calculator.
Week -2:
4. If you run a 10 kilometer race in 43 minutes 30 seconds, what is your average time per
mile? What is your average speed in miles per hour? (Hint: there are 1.61 kilometers in
a mile).
5. The volume of a sphere with radius r is 5? (Use Sphere volume formula)
6. Suppose the cover price of a book is $24.95, but bookstores get a 40% discount.
Shipping costs $3 for the first copy and 75 cents for each additional copy. What is
the total wholesale cost for 60 copies?
Week -3:
7. A function object is a value you can assign to a variable or pass as an argument. For
example, do_twice is a function that takes a function object as an argument and calls it
twice:
def do_twice(f):
f()
f()
Here’s an example that uses do_twice to call a function named print_spam twice.
def print_spam():
print 'spam'
do_twice(print_spam)
a. Type this example into a script and test it.
b. Modify do_twice so that it takes two arguments, a function object and a value, and
calls the function twice, passing the value as an argument.
c. Write a more general version of print_spam, called print_twice, that takes a string
as a parameter and prints it twice.
d. Use the modified version of do_twice to call print_twice twice, passing 'spam' as
an argument.
48 | P a g e
8. Write a function that draws a grid like the following:
+----+----+
| | |
| | |
| | |
+----+----+
| | |
| | |
| | |
| | |
+----+----+
Hint: to print more than one value on a line, you can print a comma-separated
sequence.
9. Write a function called gcd that takes parameters a and b and returns their
greatest common divisor.
10. Write a function called is_palindrome that takes a string argument and returns
True if it is a palindrome and False otherwise. Remember that you can use the
built-in function len to check the length of a string.
Week-4:
11. Write a function called is_sorted that takes a list as a parameter and returns True if the
list is sorted in ascending order and False otherwise.
12. Write a function called has_duplicates that takes a list and returns True if there is any
element that appears more than once. It should not modify the original list.
i) Write a function called remove_duplicates that takes a list and returns a new list
with
only the unique elements from the original. Hint: they don’t have to be in the same
order.
ii) The wordlist I provided, words.txt, doesn’t contain single letter words. So you might
want to add “I”, “a”, and the empty string.
iii) Write a python code to read a dictionary values from the user. Construct a function to
invert its content. i.e., keys should be values and values should be keys.
Week-5:
iv) If there are 23 students in your class, what are the chances that two of you have the
same birthday? You can estimate this probability by generating random samples of 23
birthdays and checking for matches.
Hint: you can generate random birthdays with the randint function in the random
module.
v) How does a module source code file become a module object?
vi) Why might you have to set your PYTHONPATH environment variable?
vii) What is a namespace, and what does a module’s namespace contain?
viii) How do you make a module? Give an example of construction of a module using
different geometrical shapes and operations on them as its functions.
ix) What is the purpose of a _ _init_ _.py file in a module package directory? Explain
49 | P a g e
with a suitable example.
x) Use the structure of exception handling all general purpose exceptions.
Week-6:
xi) a. Write a function called draw_rectangle that takes a Canvas and a Rectangle as
arguments and draws a representation of the Rectangle on the Canvas.
b. Add an attribute named color to your Rectangle objects and modify draw_rectangle
so that it uses the color attribute as the fill color.
c. Write a function called draw_point that takes a Canvas and a Point as arguments and
draws a representation of the Point on the Canvas.
d. Define a new class called Circle with appropriate attributes and instantiate a few
Circle objects. Write a function called draw_circle that draws circles on the canvas.
xii) Write a Python program to demonstrate the usage of MRO in multiple levels of
Inheritances.
xiii) Write a python code to read a phone number and email-id from the user and
validate it for correctness.
Week-7:
xiv) Write a Python code to merge two given file contents into third file.
xv) Write a Python code to open a given file and construct a function to check for given
words present in it and display on found.
Week-8:
xvi) Import numpy, Plotpy and Scipy and explore their functionalities.
xvii) Write a GUI program to create a window wizard having two text labels, two text
fields and two buttons as Submit and Reset.
50 | P a g e
Python Programming Lab
Week -1:
1. Use a web browser to go to the Python website
This page contains information about Python and links to Python-related pages, and it
gives you the ability to search the Python documentation.
2. Start the Python interpreter and type help() to start the online help utility.
51 | P a g e
3. Start Python interpreter and use it as Calculator.
Week -2:
4. The volume of a sphere with radius r is 5? (Use Sphere volume formula)
pi = 3.1415926535897931
2r= 6.0
V= 4.0/3.0*pi* r**3
print('The volume of the sphere is: ',V)
line that has just executed
5. Suppose the cover price of a book is $24.95, but bookstores get a 40% discount.
Shipping costs $3 for the first copy and 75 cents for each additional copy. What is the
total wholesale cost for 60 copies?
6. If you run a 10 kilometer race in 43 minutes 30 seconds, what is your average time per
mile? What is your average speed in miles per hour? (Hint: there are 1.61 kilometers in a
mile).
Week -3:
7. A function object is a value you can assign to a variable or pass as an argument. For
example, do_twice is a function that takes a function object as an argument and calls it
twice:
def do_twice(f):
f()
f()
Here’s an example that uses do_twice to call a function named print_spam twice.
def print_spam():
print 'spam'
do_twice(print_spam)
a. Type this example into a script and test it.
52 | P a g e
b. Modify do_twice so that it takes two arguments, a function object and a value, and
calls the function twice, passing the value as an argument.
c. Write a more general version of print_spam, called print_twice, that takes a string
as a parameter and prints it twice.
d. Use the modified version of do_twice to call print_twice twice, passing 'spam' as
an argument.
+----+----+
|| |
| | |
|| |
+----+----+
| | |
| | |
| | |
|| |
+----+----+
Hint: to print more than one value on a line, you can print a comma-separated
sequence.
8. Write a function called gcd that takes parameters a and b and returns their greatest com-
mon divisor.
9. Write a function called is_palindrome that takes a string argument and returns
True if it is a palindrome and False otherwise. Remember that you can use the
built-in function len to check the length of a string.
Week-4:
10. . Write a function called is_sorted that takes a list as a parameter and returns True if the
list is sorted in ascending order and False otherwise.
def is_sorted(vlist):
n=len(vlist)
i=1
flag=0
while i<n:
if (vlist[i]>vlist[i-1]):
flag+=1
else:
break
i+=1
if flag==n-1:
53 | P a g e
return 'true'
else:
return 'false'
input_string=input("Enter the list elements:")
vlist= input_string.split()
print(is_sorted(vlist))
11. Write a function called has_duplicates that takes a list and returns True if there is any
element that appears more than once. It should not modify the original list.
def has_duplicates(vlist):
n=len(vlist)
rep=[]
for i in range(n):
k=i+1
for j in range(k,n):
if vlist[i]==vlist[j]:
return 'true'
return 'false'
input_string=input("Enter the list elements:")
vlist= input_string.split()
print(has_duplicates(vlist))
12. Write a function called remove_duplicates that takes a list and returns a new list with
only the unique elements from the original. Hint: they don’t have to be in the same
order.
def remove_duplicates(vlist):
final_list = []
for num in vlist:
if num not in final_list:
final_list.append(num)
return final_list
input_string=input("Enter the list elements:")
vlist= input_string.split()
print(remove_duplicates(vlist))
13. Write a python code to read a dictionary values from the user. Construct a function to
invert its content. i.e., keys should be values and values should be keys.
def invert_dict(d):
return dict([(v, k) for k, v in d.items()])
user_input = input("Enter key and value separated by commas (,): ")
key, value = user_input.split(",")
d=dict()
d[key]=value
54 | P a g e
print(invert_dict(d))
14. The wordlist I provided, words.txt, doesn’t contain single letter words. So you might
want to add “I”, “a”, and the empty string.
Week-5:
15. If there are 23 students in your class, what are the chances that two of you have the same
birthday? You can estimate this probability by generating random samples of 23
birthdays and checking for matches.
Hint: you can generate random birthdays with the randint function in the random
module.
import random
classSize = 23
numTrials = 1000
dupeCount = 0
foundDupe = False
for num in birthdayList:
if birthdayList.count(num) > 1:
foundDupe = True
if foundDupe == True:
dupeCount = dupeCount + 1
16. How do you make a module? Give an example of construction of a module using
different geometrical shapes and operations on them as its functions.
from turtle import *
canvas = Screen()
canvas.setup(400,400)
def square():
sarah = Turtle()
sarah.forward(50)
sarah.left(90)
sarah.forward(50)
sarah.left(90)
sarah.forward(50)
sarah.left(90)
55 | P a g e
sarah.forward(50)
sarah.left(90)
canvas.exitonclick()
def rectangle():
sarah = Turtle()
sarah.forward(50)
sarah.left(90)
sarah.forward(20)
sarah.left(90)
sarah.forward(50)
sarah.left(90)
sarah.forward(20)
sarah.left(90)
canvas.exitonclick()
def hexagon():
sarah = Turtle()
sarah.forward(50)
sarah.left(60)
sarah.forward(50)
sarah.left(60)
sarah.forward(50)
sarah.left(60)
sarah.forward(50)
sarah.left(60)
sarah.forward(50)
sarah.left(60)
sarah.forward(50)
17. What is the purpose of a _ _init_ _.py file in a module package directory? Explain with
a suitable example.
class Rectangle:
def __init__(self, length, breadth, unit_cost=0):
self.length = length
self.breadth = breadth
self.unit_cost = unit_cost
def get_area(self):
return self.length * self.breadth
def calculate_cost(self):
area = self.get_area()
return area * self.unit_cost
r = Rectangle(160, 120, 2000)
print("Area of Rectangle: %s sq units" % (r.get_area()))
18. Use the structure of exception handling all general purpose exceptions.
try:
fh = open("testfile", "w")
56 | P a g e
try:
fh.write("This is my test file for exception handling!!")
finally:
print("Going to close the file")
fh.close()
except IOError:
print("Error: can\'t find file or read data")
19. How does a module source code file become a module object?
20. Why might you have to set your PYTHONPATH environment variable?
Week-6:
22.a. Write a function called draw_rectangle that takes a Canvas and a Rectangle as
arguments and draws a representation of the Rectangle on the Canvas.
p = Point()
p.x = 60
p.y = 15
class Rectangle(object):
"""Represents a rectangle."""
box = Rectangle()
box.color = 'blue'
box.bbox = [[-100, -60],[100, 60]]
class Canvas(object):
"""Represents a canvas.
attributes: width, height, background color"""
a_canvas = Canvas()
a_canvas.width = 500
a_canvas.height = 500
world = World()
draw_czech_republic_flag(a_canvas)
world.mainloop()
b. Write a function called draw_point that takes a Canvas and a Point as arguments
and draws a representation of the Point on the Canvas.
57 | P a g e
"represents a point in 2-D space"
p = Point()
p.x = 60
p.y = 15
class Canvas(object):
"""Represents a canvas.
attributes: width, height, background color"""
a_canvas = Canvas()
a_canvas.width = 500
a_canvas.height = 500
world = World()
draw_czech_republic_flag(a_canvas)
world.mainloop()
c. Define a new class called Circle with appropriate attributes and instantiate a few
Circle objects. Write a function called draw_circle that draws circles on the canvas.
d. Add an attribute named color to your Rectangle objects and modify draw_rectan-
gle so that it uses the color attribute as the fill color.
23. Write a Python program to demonstrate the usage of MRO in multiple levels of
inheritances.
class Person:
#defining constructor
def __init__(self, personName, personAge):
self.name = personName
self.age = personAge
def showAge(self):
print(self.age)
58 | P a g e
def __init__(self, studentId):
self.studentId = studentId
def getId(self):
return self.studentId
24.Write a python code to read a phone number and email-id from the user and validate it
for correctness.
Week-7:
25. Write a Python code to merge two given file contents into third file.
import shutil;
print("Enter 'x' for exit.");
filename1 = input("Enter first file name to merge: ");
if filename1 == 'x':
exit();
else:
filename2 = input("Enter second file name to merge: ");
filename3 = input("Create a new file to merge content of two file inside this
file: ");
print();
print("Merging the content of two file in",filename3);
with open(filename3, "wb") as wfd:
for f in [filename1, filename2]:
with open(f, "rb") as fd:
shutil.copyfileobj(fd, wfd, 1024*1024*10);
print("\nContent merged successfully.!");
print("Want to see ? (y/n): ");
check = input();
if check == 'n':
exit();
else:
print();
59 | P a g e
c = open(filename3, "r");
print(c.read());
c.close();
def txt_search_m(self):
files = [f for f in os.listdir(self.path1) if os.path.isfile(self.path1+"/"+f)]
file_number = 0
for file in files:
file_t = open(self.path1+"/"+file)
line_number=1
flag_file = 0
for line1 in file_t:
if self.i:
line1 = line1.lower()
if re.search(self.string2, line1):
flag_file= 1
print "The text "+self.string1+" found in ", file, " at line number ",line_number
line_number=line_number+1
if flag_file == 1:
file_number=file_number+1
flag_file=0
file_t.close()
print "total files are ",file_number
Week-8:
25. Import numpy, Plotpy and Scipy and explore their
functionalities.
NumPy - Introduction
NumPy is a Python package. It stands for 'Numerical Python'. It is a library con-
sisting of multidimensional array objects and a collection of routines for process-
ing of array.
Numeric, the ancestor of NumPy, was developed by Jim Hugunin. Another package Numarray
was also developed, having some additional functionalities. In 2005, Travis Oliphant created
NumPy package by incorporating the features of Numarray into Numeric package. There are
many contributors to this open source project.
60 | P a g e
3. Operations related to linear algebra. NumPy has in-built functions for linear algebra
and random number generation.
4. o install NumPy, run the following command.
5. Python setup.py install
6. To test whether NumPy module is properly installed, try to import it from Python
prompt.
7. import numpy
8. If it is not installed, the following error message will be displayed.
9. Traceback (most recent call last):
10. File "<pyshell#0>", line 1, in <module>
11. import numpy
12. ImportError: No module named 'numpy'
Alternatively, NumPy package is imported using the following syntax –
Example 1
import numpy as np
import numpy as np
a = np.array([1,2,3])
print a
The output is as follows −
[1, 2, 3]
Example 2
# more than one dimensions
import numpy as np
a = np.array([[1, 2], [3, 4]])
print a
The output is as follows −
[[1, 2]
[3, 4]]
Example 3
# minimum dimensions
import numpy as np
a = np.array([1, 2, 3,4,5], ndmin = 2)
print a
The output is as follows −
[[1, 2, 3, 4, 5]]
Example 4
# dtype parameter
61 | P a g e
import numpy as np
a = np.array([1, 2, 3], dtype = complex)
print a
The output is as follows −
[ 1.+0.j, 2.+0.j, 3.+0.j]
62 | P a g e
SciPy - Introduction
SciPy, a scientific library for Python is an open source, BSD-licensed library for mathematics,
science and engineering. The SciPy library depends on NumPy, which provides convenient and
fast N-dimensional array manipulation. The main reason for building the SciPy library is that, it
should work with NumPy arrays. It provides many user-friendly and efficient numerical prac-
tices such as routines for numerical integration and optimization. This is an introductory tutorial,
which covers the fundamentals of SciPy and describes how to deal with its various modules.
Example 1
ip install plotly "notebook>=5.3" "ipywidgets>=7.2"
Inside Jupyter notebook:
import plotly.graph_objs as go
fig = go.FigureWidget()
# Display an empty figure
fig
# Add a scatter chart
fig.add_scatter(y=[2, 1, 4, 3])
# Add a bar chart
fig.add_bar(y=[1, 4, 3, 2])
# Add a title
fig.layout.title = 'Hello FigureWidget'
See the Python documentation for more examples.
63 | P a g e
Plotly - Introduction
plotly.py is an interactive, open-source, and browser-based graphing library for
Python :sparkles:
Built on top of plotly.js, plotly.py is a high-level, declarative charting library. plotly.js
ships with over 30 chart types, including scientific charts, 3D graphs, statistical charts,
SVG maps, financial charts, and more.
plotly.py is MIT Licensed. Plotly graphs can be viewed in Jupyter notebooks, stand-
alone HTML files, or hosted online on plot.ly.
N = 100
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
sz = np.random.rand(N)*30
fig = go.Figure()
fig.add_scatter(x=x,
y=y,
mode='markers',
marker={'size': sz,
'color': colors,
'opacity': 0.6,
'colorscale': 'Viridis'
});
iplot(fig)
import plotly.plotly as py
import plotly.graph_objs as go
N = 500
random_x = np.linspace(0, 1, N)
random_y = np.random.randn(N)
# Create a trace
64 | P a g e
trace = go.Scatter(
x = random_x,
y = random_y
)
data = [trace]
py.iplot(data, filename='basic-line')
import plotly.plotly as py
import plotly.graph_objs as go
data = [go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[20, 14, 23]
)]
py.iplot(data, filename='basic-bar')
labels = ['Oxygen','Hydrogen','Carbon_Dioxide','Nitrogen']
values = [4500,2500,1053,500]
py.iplot([trace], filename='basic_pie_chart')
Our first GUI will be a window with a label and two buttons:
from tkinter import Tk, Label, Button
class MyFirstGUI:
def __init__(self,master):
self.master = master
master.title("A simple GUI")
65 | P a g e
self.label = Label(master, text="This is our first GUI!")
self.label.pack()
def greet(self):
print("Greetings!")
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
def write_slogan():
print("Tkinter is easy to use!")
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
button = tk.Button(frame,
text="QUIT",
fg="red",
command=quit)
button.pack(side=tk.LEFT)
slogan = tk.Button(frame,
text="Hello",
command=write_slogan)
slogan.pack(side=tk.LEFT)
root.mainloop()
66 | P a g e
The result of the previous example looks like this:
67 | P a g e
SREENIDHI INSTITUTE OF SCIENCE & TECHNOLOGY
(AN AUTONOMOUS INSTITUTION UNDER JNTUH)
(Approved by AICTE & Aided by World Bank under TEQIP )
Yamnampet, Ghatkesar Mandal, Hyderabad - 501 301.
For
B. Tech. II year – II SEM
ELECTRONICS AND COMPUTER ENGINEERING
DEPARTMENT
OF
ELECTRONICS AND COMPUTER ENGINEERING
68 | P a g e
DATABASE MANAGEMENT SYSTEMS LABORATORY SYLLABUS
L T P/D C
- - 3 2
1. Creation, altering and droping of tables and inserting rows into a table (use
constraints while creating tables) examples using SELECT command.
2. Queries (along with sub Queries) using ANY, ALL, IN, EXISTS,
NOTEXISTS, UNION, INTERSET, Constraints.
Example: - Select the roll number and name of the student who secured fourth
rank in the class.
3. Queries using Aggregate functions (COUNT, SUM, AVG, MAX and MIN),
GROUP BY, HAVING and Creation and dropping of Views.
4. Queries using Conversion functions (to_char, to_number and to_date), string
functions
(Concatenation, lpad, rpad, ltrim, rtrim, lower, upper, initcap, length, substr
and instr), date functions (Sysdate, next_day, add_months, last_day,
months_between, least, greatest, trunc, round, to_char, to_date)
5. i) Creation of simple PL/SQL program which includes declaration
section, executable section and exception –Handling section (Ex.
Student marks can be selected from the table and printed for those
who secured first class and an exception can be raised if no records
were found)
ii) Insert data into student table and use COMMIT, ROLLBACK and
SAVEPOINT in PL/SQL block.
6. Develop a program that includes the features NESTED IF, CASE and CASE
expression. The program can be extended using the NULLIF and
COALESCE functions.
7. Program development using WHILE LOOPS, numeric FOR LOOPS, nested
loops using ERROR Handling, BUILT –IN Exceptions, USE defined
Exceptions, RAISE- APPLICATION ERROR.
8. Programs development using creation of procedures, passing parameters IN
and OUT of PROCEDURES.
69 | P a g e
9. Program development using creation of stored functions, invoke functions in
SQL Statement and write complex functions.
1. Program development using creation of package specification, package
bodies, private objects, package variables and cursors and calling stored
packages.
2. Develop programs using features parameters in a CURSOR, FOR
UPDATE CURSOR, WHERE CURRENT of clause and CURSOR
variables.
3. Develop Programs using BEFORE and AFTER Triggers, Row and
Statement Triggers and INSTEAD OF Triggers
TEXT BOOKS
70 | P a g e
List1
1. Create Sailors table with the following fields and describe the table (sid:
integer, sname: string, rating: integer)
2. Add field (age: integer) to the Sailors table and describe the table
3. Modify field age to real in the Sailors table and describe the table
4. Delete age field from the Sailors table and describe the table
5. Add field (age: real) to the Sailors table and describe the table
7. Create Sailors table with the following fields and describe the table (sid:
integer, sname: string, rating: integer, age: real)
71 | P a g e
9. Retrieve all Records from the Sailors table
11. Retrieve the names and ages of all sailors from the Sailors table
13. Create Sailors1 table with the following fields and describe the table (sid:
integer, sname: string, rating: integer, age: real)
19. Create Boats table with the following fields and describe the table (bid: integer,
bname: string, color: string)
22. Create Reserves table with the following fields and describe the table (sid: integer,
bid: integer, day: date)
72 | P a g e
23. Insert the following records in to the Reserves table
73 | P a g e
List -1 Solutions
1. Create Sailors table with the following fields and describe the
table (sid: integer, sname: string, rating: integer)
Query: Create table Sailors(sid number(2),sname varchar2(20),rating number(2))
Output: Table Created
Query: desc Sailors
Output:
Bottom of Form
Name Null? Type
SID NUMBER(2)
SNAME VARCHAR2(20)
RATING NUMBER(2)
2. Add field (age: integer) to the Sailors table and describe the table
3. Modify field age to real in the Sailors table and describe the table
74 | P a g e
Name Null? Type
SID NUMBER(2)
SNAME VARCHAR2(10)
RATING NUMBER(2)
AGE NUMBER(3,1)
4. Delete age field from the Sailors table and describe the table
5. Add field (age: real) to the Sailors table and describe the table
Query:
insert into Sailors values(22,'Dustin',7,45.0);
insert into Sailors values(29,'Brutus',1,33.0);
insert into Sailors values(31,'Lubber',8,55.5);
insert into Sailors values(32,'Andy',8,25.5);
insert into Sailors values(58,'Rusty',10,35.0);
insert into Sailors values(64,'Horatio',7,35.0);
insert into Sailors values(71,'Zorba',10,16.0);
76 | P a g e
insert into Sailors values(74,'Horatio',9,35.0);
insert into Sailors values(85,'Art',3,25.5);
insert into Sailors values(95,'Bob',3,63.5);
Output:
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
77 | P a g e
Bottom of Form
SNAME AGE
Andy 25.5
Art 25.5
Bob 63.5
Brutus 33
Dustin 45
Horatio 35
Lubber 55.5
Rusty 35
Zorba 16
9 records selected.
11. Retrieve the names and ages of all sailors from the Sailors table
Query: select sname,age from sailors
Output:
Bottom of Form
SNAME AGE
Dustin 45
Brutus 33
Lubber 55.5
Andy 25.5
Rusty 35
Horatio 35
Zorba 16
Horatio 35
Art 25.5
Bob 63.5
10 records selected.
12. Find all sailors with a rating above 7
Query: select * from sailors where rating>7
Output:
Bottom of Form
SID SNAME RATING AGE
31 Lubber 8 55.5
32 Andy 8 25.5
78 | P a g e
58 Rusty 10 35
71 Zorba 10 16
74 Horatio 9 35
5 records selected
13. Create Sailors1 table with the following fields and describe the table
(sid: integer, sname: string, rating: integer, age: real)
79 | P a g e
71 Zorba 10 16
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
10 records selected
16. Delete sailor from the Sailors1 table whose sid is 58
Query: DELETE FROM Sailors1
WHERE sid=58
Output: 1 row deleted.
19. Create Boats table with the following fields and describe the table
(bid: integer, bname: string, color: string)
80 | P a g e
Top of Form
Bottom of Form
Name Null? Type
BID NUMBER(3)
BNAME VARCHAR2(9)
COLOR VARCHAR2(5)
Query:
insert into boats values(101,'Interlake','blue');
insert into boats values(102,'Interlake','red');
insert into boats values(103,'Clipper','green');
insert into boats values(104,'Marine','red');
Output:
1 row created.
1 row created.
1 row created.
1 row created.
21. Retrieve all Records from the Boats table
81 | P a g e
103 Clipper green
104 Marine red
4 records selected
22. Create Reserves table with the following fields and describe the table
(sid: integer, bid: integer, day: date)
Bottom of Form
Name Null? Type
SID NUMBER(2)
BID NUMBER(3)
DAY DATE
Query:
insert into reserves values(22,101,'10-oct-98');
insert into reserves values(22,102,'10-oct-98');
insert into reserves values(22,103,'10-aug-98');
insert into reserves values(22,104,'10-jul-98');
insert into reserves values(31,102,'11-oct-98');
insert into reserves values(31,103,'11-jun-98');
insert into reserves values(31,104,'11-dec-98');
82 | P a g e
insert into reserves values(64,101,'9-may-98');
insert into reserves values(64,102,'9-aug-98');
insert into reserves values(74,103,'9-aug-98');
Output:
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
83 | P a g e
List2
1. Find the names of sailors who have reserved boat number 103 (using AND op-
erator)
2. Find all sailors whose age is in between 45.0 and 63.5 (using BETWEEN oper-
ator)
3. Find all sailors whose age is in the list of values(15.0,33.2,45.7,63.5) (using IN
operator)
4. Find all sailors whose second letter in the names contain ‘u’
5. Find all sailors whose first letter and third letter in the names are ‘A’ and ‘d’
6. Find all sailors from sailors and sailors1 table by using UNION operator
7. Find all sailors from sailors and sailors1 table by using INTERSECT operator
8. Find all sailors from sailors and sailors1 table by using MINUS operator
9. Find the names of sailors who have reserved boat 103 (using nested query)
10.Find the names of sailors who have reserved a blue boat (using nested query)
11.Find the names of sailors who have not reserved a red boat (using nested query)
12.Find the names of sailors who have reserved boat 103 (using Correlated Nested
Query)
13.Find sailors whose rating is better than some sailor called Horatio (using ANY
operator)
14.Find sailors whose rating is better than some sailor called Horatio (using ALL
operator)
15.Find the sailors with the highest rating
16.Find the average age of all sailors
17.Find the minimum age of the sailor
18.Find the maximum age of the sailor
19.Count the number of sailors
20.Count the number of different sailor names
84 | P a g e
List -2 Solutions
1. Find the names of sailors who have reserved boat number 103
(using AND operator)
Query: select sname from Sailors S,reserves R
where S.sid=R.sid and R.bid=103;
Output:
Bottom of Form
SNAME
Dustin
Lubber
Horatio
2. Find all sailors whose age is in between 45.0 and 63.5 (using
BETWEEN operator)
Query: select * from Sailors
where age between 45.0 and 63.5
Output:
Bottom of Form
SID SNAME RATING AGE
31 Lubber 8 55.5
95 Bob 3 63.5
22 Dustin 7 45
4. Find all sailors whose second letter in the names contain ‘u’
Query: select * from Sailors
where sname like '_u%'
Output:
Bottom of Form
85 | P a g e
SID SNAME RATING AGE
31 Lubber 8 55.5
58 Rusty 10 35
22 Dustin 7 45
5. Find all sailors whose first letter and third letter in the names are
‘A’ and ‘d’
Query: select * from Sailors
where sname like 'A_d%'
Output:
Bottom of Form
SID SNAME RATING AGE
32 Andy 8 25.5
6. Find all sailors from sailors and sailors1 table by using (UNION
operator)
Query: select * from Sailors
union select * from Sailors1
Output:
Bottom of Form
SID SNAME RATING AGE
22 Dustin 7 45
29 Brutus 1 33
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
64 Horatio 7 35
71 Zorba 10 16
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
10 rows selected.
86 | P a g e
Query: select * from Sailors
intersect select * from Sailors1
Output:
Bottom of Form
SID SNAME RATING AGE
22 Dustin 7 45
29 Brutus 1 33
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
64 Horatio 7 35
71 Zorba 10 16
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
8. Find all sailors from sailors and sailors1 table by using MINUS
operator
Query: select * from Sailors
minus select * from Sailors1
Output:
Bottom of Form
SID SNAME RATING AGE
58 Rusty 10 35
9. Find the names of sailors who have reserved boat 103 (using
nested query)
Query: select sname from Sailors
where sid in(select sid from reserves where bid =103);
Output:
Bottom of Form
SNAME
Dustin
Lubber
Horatio
87 | P a g e
10. Find the names of sailors who have reserved a blue boat (using
nested query)
Query: select sname from Sailors
where sid in(select sid from reserves where bid in(select bid from boats
where color='blue'));
Output:
Bottom of Form
SNAME
Dustin
Horatio
11. Find the names of sailors who have not reserved a red boat
(using nested query)
Query: select sname from Sailors
where sid in(select sid from reserves where bid in(select bid from boats
where color!='red'));
Output:
Bottom of Form
SNAME
Dustin
Lubber
Horatio
Horatio
12. Find the names of sailors who have reserved boat 103 (using
Correlated Nested Query)
Query: select s.sname from Sailors s
where exists(select * from reserves r where
r.bid=103 and r.sid=s.sid);
Output:
Bottom of Form
SNAME
Lubber
Horatio
Dustin
88 | P a g e
13. Find sailors whose rating is better than some sailor called
Horatio (using ANY operator)
Query: select * from Sailors
where rating> any(select rating from Sailors where sname='Horatio');
Output:
Bottom of Form
SID SNAME RATING AGE
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
71 Zorba 10 16
74 Horatio 9 35
14. Find sailors whose rating is better than some sailor called
Horatio (using ALL operator)
Query: select * from Sailors
where rating> all(select rating from Sailors where sname='Horatio');
Output:
Bottom of Form
SID SNAME RATING AGE
58 Rusty 10 35
71 Zorba 10 16
89 | P a g e
36.9
17. Find the minimum age of the sailor
Query: select min(age) from Sailors
Output:
Bottom of Form
MIN(AGE)
16
18. Find the maximum age of the sailor
Query: select max(age) from Sailors
Output:
Bottom of Form
MAX(AGE)
63.5
19. Count the number of sailors
Query: select count(*) from Sailors
Output:
Bottom of Form
COUNT(*)
10
20. Count the number of different sailor names
Query: select count(distinct sname) from Sailors
Output:
Bottom of Form
COUNT(DISTINCT SNAME)
9
List – 3
90 | P a g e
Find the age of the youngest sailor for each rating level
Find the age of the youngest sailor for each rating level, which is greater
than 7
Find the age of the youngest sailor who is eligible to vote (i.e., is at least
18 years old) for each rating level with at least two such sailors
Find the average age of sailors for each rating level that has at least two
sailors
Drop sailors table
Create Sailors table with the following fields and describe the table
(sid: integer, sname: string, rating: integer, age: real)
Note: Underlined attribute represents the primary key
Insert records in to the Sailors table
Drop Reserves table
Create Reserves table with the following fields and describe the table
(sid: integer, bid: integer, day: date)
Insert records in to the Reserves table
Drop Boats table
1. Create Boats table with the following fields and describe the table (bid: integer,
bname: string, color: string).
2. Insert records in to the Boats table
3. For each red boat, find the number of reservations for this boat.
4. Find those ratings for which the average age of sailors is the minimum over all
ratings
5. Count the number of sailors who have reserved boats between '9/5/98' and
'10/10/98'
6. Find the names of sailors who have reserved boats between '9/4/98' and '1/8/98'
7. Find the number of reservations made for each boat
8. Find the number of reservations (with at least three) made for each boat
9. Find the number of reservations made for each boat during '9/5/98' and
'10/10/98'
10.Find the days on which blue color boat is reserved
11.Find the days on which 'Horatio' reserved the boats
12.Find the number of boat reservations made by each sailor
13.Find the number of boats in each color
14.Find the colors of boats reserved by ‘Lubber’
LIST – 3 Solutions
91 | P a g e
1. Find the sum of ratings of all sailors
Query: select sum(rating) from Sailors
Output:
Bottom of Form
SUM(RATING)
66
92 | P a g e
G NG)
1 1
3 2
7 2
8 2
9 1
10 2
6. Find the age of the youngest sailor for each rating level
Query: select rating,min(age) from Sailors
group by rating
Output:
Bottom of Form
RATING MIN(AGE)
1 33
3 25.5
7 35
8 25.5
9 35
10 16
7. Find the age of the youngest sailor for each rating level, which is
greater than 7
Query: select rating,min(age) from Sailors
group by rating
having rating>7
Bottom of Form
RATING MIN(AGE)
8 25.5
9 35
10 16
8. Find the age of the youngest sailor who is eligible to vote (i.e., is at
least 18 years old) for each rating level with at least two such sailors
Query: select rating,min(age) from Sailors
where age>=18
group by rating
93 | P a g e
having count (rating)>=2
Output:
Bottom of Form
RATING MIN(AGE)
3 25.5
7 35
8 25.5
9. Find the average age of sailors for each rating level that has at
least two sailors
Query: select rating,avg(age) from Sailors
group by rating
having count (rating)>=2
Output:
Bottom of Form
RATING AVG(AGE)
3 44.5
7 40
8 40.5
10 25.5
11. Create Sailors table with the following fields and describe the
table (sid: integer, sname: string, rating: integer, age: real)
Note: Underlined attribute represents the primary key
Query: CREATE TABLE Sailors (sid NUMBER(2) primary key, sname
VARCHAR2(20),rating NUMBER(2),age NUMBER(3,1))
Output:
Table created.
Query: desc Sailors
Output:
Bottom of Form
Name Null? Type
SID NOT NULL NUMBER(2)
94 | P a g e
SNAME VARCHAR2(20)
RATING NUMBER(2)
AGE NUMBER(3,1)
17. Create Boats table with the following fields and describe the
table (bid: integer, bname: string, color: string).
Query: create table boats(bid number(3) primary key,bname varchar2(9),color
varchar2(5))
Output: Table Created
96 | P a g e
Query: desc boats
Output:
Bottom of Form
Name Null? Type
BID NOT NULL NUMBER(3)
BNAME VARCHAR2(9)
COLOR VARCHAR2(5)
18. Insert records in to the Boats table
Query:
insert into boats values(101,'Interlake','blue');
insert into boats values(102,'Interlake','red');
insert into boats values(103,'Clipper','green');
insert into boats values(104,'Marine','red');
Output:
1 row created.
1 row created.
1 row created.
1 row created.
19. For each red boat, find the number of reservations for this boat.
Query: select bid,count(bid) from reserves
where bid in(select bid from boats where color='red')
group by bid
Output:
Bottom of Form
BID COUNT(BID)
102 3
104 2
20. Find those ratings for which the average age of sailors is
the minimum over all ratings
Query: select temp1.rating,temp1.ave age from (select rating,avg(age) ave from
sailors group by rating) temp1
where temp1.ave=(select min(temp2.ave) from (select rating,avg(age) ave
from sailors group by rating) temp2)
97 | P a g e
Output:
Bottom of Form
RATING AGE
10 25.5
21. Count the number of sailors who have reserved boats between
'9/5/98' and '10/10/98'
Query: select count(sid) from reserves
where day between '9-may-98' and '10-oct-98'
Output:
Bottom of Form
COUNT(SID)
8
22. Find the names of sailors who have reserved boats between
'9/4/98' and '1/8/98'
Query: select sname from sailors
where sid in(select sid from reserves where day between '9-apr-98' and '1-aug-
98')
Output:
Bottom of Form
SNAME
Dustin
Lubber
Horatio
98 | P a g e
24. Find the number of reservations (with at least three) made for
each boat
Query: select bid,count(bid) from reserves
group by bid
having count(bid)>=3
Output:
Bottom of Form
BID COUNT(BID)
102 3
103 3
25. Find the number of reservations made for each boat during
'9/5/98' and '10/10/98'
Query: select bid,count(bid) from reserves
where day between '9-may-98' and '10-oct-98'
group by bid
Output:
Bottom of Form
BID COUNT(BID)
101 2
102 2
103 3
104 1
26. Find the days on which blue color boat is reserved
Query: select day from reserves where bid in( select bid from boats where
color='blue')
Output:
Bottom of Form
DAY
10-OCT-98
09-MAY-98
27. Find the days on which 'Horatio' reserved the boats
Query: select day from reserves where sid in(select sid from sailors where
sname='Horatio')
Output:
Bottom of Form
DAY
09-MAY-98
99 | P a g e
09-AUG-98
09-AUG-98
28. Find the number of boat reservations made by each sailor
Query: select s.sname,count(*)from sailors s, reserves r
where s.sid=r.sid
group by s.sname;
Output:
Bottom of Form
SNAME COUNT(*)
Dustin 4
Horatio 3
Lubber 3
29. Find the number of boats in each color
Query: select count(bid),color from boats
group by color
Output:
Bottom of Form
COUNT(BID) COLOR
1 blue
1 green
2 red
30. Find the colors of boats reserved by ‘Lubber’
Query: select distinct color from boats where bid in
(select bid from reserves where sid in
(select sid from sailors where sname='Lubber'))
Output:
Bottom of Form
COLOR
green
red
100 | P a g e
List4
1.Create Persons table with the following fields (declare FirstName as DE-
FAULT 'Ola') and describe the table
101 | P a g e
List-4 Solutions
102 | P a g e
create table Orders (Oid number(2) PRIMARY KEY,OrderNo number(5),Pid
number(2),FOREIGN KEY(Pid ) REFERENCES Persons(Pid));
Output:
Table created.
5. Insert Persons records in to Persons table
Query:
insert into persons(pid,lastname,address,city) values(1,'Hansen','Timotevin
10','Sandnes');
Output:
1 row created.
Query:
Select * from persons;
Output:
103 | P a g e
Bottom of Form
OID ORDERNO PID
1 77895 3
2 44678 3
3 22456 2
4 24562 1
7. Insert (4,'Andy','Hansen','Storgt 20','Stavanger') record in to Persons ta-
ble and observe the result
Query:
insert into persons values(4,'Andy','Hansen','Storgt 20','Stavanger');
Output:
ERROR: ORA-00001: unique constraint (SCOTT.SYS_C005118) violated
8. Insert (3,'Andy','Tahsen','Storgt 20','Stavanger') record in to Persons table
and observe the result
Query:
insert into persons values(3,'Andy','Tahsen','Storgt 20','Stavanger');
Output:
ERROR: ORA-00001: unique constraint (SCOTT.SYS_C005119) violated
9. Insert (5,51212,4) record in to Orders table and observe the result
Query:
insert into orders values(5,51212,4);
Output:
ERROR: ORA-02291: integrity constraint (SCOTT.SYS_C005121) violated -
parent key not found
10.Delete record from the Persons table whose Pid is 3 and observe the result
Query:
delete from Persons where Pid=3;
Output:
ERROR: ORA-02292: integrity constraint (SCOTT.SYS_C005121) violated -
child record found
11.Give example which includes all Arithmetic functions
Query:
select abs(4.55),ceil(4.55),floor(4.55), mod(5,4),power(2,3),sign(-10), sign(10),
sqrt(9),round(4.333,2),trunc(4.333,2) from dual
Output:
Top of Form
Bottom of Form
104 | P a g e
SIG
ABS(4. CEIL(4. FLOOR( MOD( POWER( SIGN( SQRT ROUND(4.3 TRUNC(4.3
N(-
55) 55) 4.55) 5,4) 2,3) 10) (9) 33,2) 33,2)
10)
4.55 5 4 1 8 -1 1 3 4.33 4.33
12.Give example which includes all String functions
Query:
select ascii('A'),chr(65),concat('abc','def'),instr('abaabcab','ab',1,2),substr('abcd',2)
from dual
Output:
Top of Form
Bottom of Form
ASCII('A') C CONCAT INSTR('ABAABCAB','AB',1,2) SUB
65 A abcdef 4 bcd
select length('abcd'),lengthb('abcde'),lower('ABCD'),lpad('abcd',7,'e'),
ltrim('abcd','a') from dual
Output:
Bottom of Form
LENGTH('ABCD') LENGTHB('ABCDE') LOWE LPAD('A LTR
4 5 abcd eeeabcd bcd
select replace('abcd','a','ef'),rtrim('abcd','d'),rpad('abcd',7,'e'),to_char(123) from dual
Output:
Top of Form
Bottom of Form
REPLA RTR RPAD('A TO_
efbcd abc abcdeee 123
select substr('abcdef',2,3),translate('abcdef','bc','ef'),upper('abcd'),initcap('abcd')
from dual
Output:
Top of Form
Bottom of Form
SUB TRANSL UPPE INIT
bcd aefdef ABCD Abcd
13.Give example which includes all Date and Time functions
Query:
105 | P a g e
select add_months(current_date,5),current_date,current_timestamp(2),to_date('10-
10-2011','dd-mm-yy'),months_between('10-oct-2011','10-oct-2010'),
EXTRACT(year from current_date),to_char(current_date,'mon dd yyyy')
from dual
Output:
Bottom of Form
MONTHS_
ADD_ CURR CURRENT_ TO_ BETWEEN( EXTRACT(YEARF TO_CH
MONT ENT_ TIMESTAM DAT '10-OCT- ROMCURRENT_D AR(CU
H D P(2) E(' 2011','10- ATE) R
OCT-2010')
10- 10- 10-NOV-12 10-
nov 10
APR- NOV- 02.25.41.00 OCT- 12 2012
2012
13 12 PM +05:30 11
01
14.Retrieve tuples from the reserves table (display ‘day’ as dd-mon-yyyy)
Query:
select sid,bid,to_char(day,'dd-mon-yyyy') day from reserves
Output:
Top of Form
Bottom of Form
SID BID DAY
22 101 10-OCT-1998
22 102 10-OCT-1998
22 103 10-AUG-1998
22 104 10-JUL-1998
31 102 11-OCT-1998
31 103 11-JUN-1998
31 104 11-DEC-1998
64 101 09-MAY-1998
64 102 09-AUG-1998
74 103 09-AUG-1998
15. Retrieve tuples from the boats table, in which trim 'In' from left side on
‘bname’
Query:
select ltrim(bname,'In') from boats
Output:
106 | P a g e
Top of Form
Bottom of Form
LTRIM(BNAME,'IN)
terlake
terlake
Clipper
Marine
16.Retrieve tuples from the sailors table, in which trim 'io' from right side on
‘sname’
Query:
select rtrim(sname,'io') from sailors
Output:
Bottom of Form
RTRIM(SNAM
Dustin
Brutus
Lubber
Andy
Rusty
Horat
Zorba
Horat
Art
Bob
17.Convert ‘2010 10 feb’ in to date
Query:
select to_date('2010 10 feb','yyyy dd mon') todate from dual
Output:
TODATE
10-FEB-10
107 | P a g e
Top of Form
Bottom of Form
SID SNAME CAST(SIDAS
22 Dustin 22
29 Brutus 29
31 Lubber 31
32 Andy 32
58 Rusty 58
64 Horatio 64
71 Zorba 71
74 Horatio 74
85 Art 85
95 Bob 95
Query:
create table cal(id number);
Output:
Table created.
Query:
insert into cal values(10);
insert into cal(id) values(null);
insert into cal values(20);
Query:
select * from cal
Output:
ID
10
20
Query:
select id,nullif(id,10),nvl(id,88),nvl2(id,66,88) from cal
Output:
Top of Form
Bottom of Form
ID NULLIF(ID,10) NVL(ID,88) NVL2(ID,66,88)
108 | P a g e
10 10 66
88 88
20 20 20 66
Query:
select sid,decode(sid,22,'A',31,'B','ZZ') results from sailors
Output:
Top of Form
Bottom of Form
SID RE
22 A
29 ZZ
31 B
32 ZZ
58 ZZ
64 ZZ
71 ZZ
74 ZZ
85 ZZ
95 ZZ
109 | P a g e
List5
1. Write a PL/SQL program to perform the following:
Insert <99,'John',9,25.6> into the Sailors table, Update sname 'John' to 'Joe' in the
Sailors table, Delete tuple from the Sailors table whose sname is 'Joe'
2. Retrieve tuple from the Sailors table whose sname is 'Lubber' using PL/SQL pro-
gram
3. Write a PL/SQL program to find largest and smallest of three numbers
4. Write a PL/SQL program to check whether a number is prime or not?
5. Write a PL/SQL program to check whether a number is palindrome or not?
6. Write a PL/SQL program to show handling of Pre-defined exception
7. Write a PL/SQL program to show handling of User-defined exception
8. Write a PL/SQL program to print the following values
0 if a=0
1 if a>0
-1 if a<0
9. Write a PL/SQL program to find even numbers and odd numbers in a given range
m to n
10.Write a PL/SQL program to find armstrong numbers in a given range m to n
11.Write a PL/SQL program to retrieve records from the sailors table using cursor
12.Write a PL/SQL procedure to find factorial of a given number
13.Write a PL/SQL procedure to print first n fibonacci numbers
14.Write a PL/SQL function to find sum of digits of a number
15.Write a PL/SQL recursive function to find factorial of a number
16. Explain Packages with PL/SQL program
110 | P a g e
List-5 Solutions
1. Write a PL/SQL program to perform the following: Insert
<99,'John',9,25.6> into the Sailors table, Update sname 'John' to 'Joe' in the
Sailors table, Delete tuple from the Sailorstable whose sname is 'Joe'
Program:
DECLARE
s_id number(2):=99;
s_name varchar2(20):='john';
s_rating number(2):=9;
s_age number(3,1):=25.6;
BEGIN
INSERT INTO Sailors VALUES(s_id,s_name,s_rating,s_age);
end;
Output:
SID SNAME RATING AGE
22 Dustin 7 45
29 Brutus 1 33
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
64 Horatio 7 35
71 Zorba 10 16
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
99 john 9 25.6
11 rows selected.
Program:
begin
update sailors set sname='joe' where sname='john';
end;
Output:
SID SNAME RATING AGE
22 Dustin 7 45
29 Brutus 1 33
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
64 Horatio 7 35
71 Zorba 10 16
111 | P a g e
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
99 joe 9 25.6
11 rows selected.
Program:
begin
delete from sailors where sname='joe';
end;
Output:
SID SNAME RATING AGE
22 Dustin 7 45
29 Brutus 1 33
31 Lubber 8 55.5
32 Andy 8 25.5
58 Rusty 10 35
64 Horatio 7 35
71 Zorba 10 16
74 Horatio 9 35
85 Art 3 25.5
95 Bob 3 63.5
10 rows selected.
2. Retrieve tuple from the Sailors table whose sname is 'Lubber' using
PL/SQL program
Program:
declare
s_id sailors.sid%type;
s_sname sailors.sname%type;
s_rating sailors.rating%type;
s_age sailors.age%type;
begin
select sid,sname,rating,age into s_id,s_sname,s_rating,s_age from sailors
where sname='lubber';
dbms_output.put_line('sid is '||s_id||' sname is'||s_sname||' rating'||s_rating||' age i
s'||s_age);
end;
Output:
sid is 31 sname is lubber rating is 8 age is 55.5
3. Write a PL/SQL program to find largest and smallest of three numbers
Program:
112 | P a g e
declare
a number(2):=10;
b number(2):=5;
c number(2):=15;
large number(2):=0;
small number(2):=0;
begin
if b>a and b>c then
large:=b;
elsif c>b and c>a then
large:=c;
else
large:=a;
end if;
dbms_output.put_line('largest number is'||large);
if b<a and b<c then
small:=b;
elsif c<b and c<a then
small:=c;
else
small:=a;
end if;
dbms_output.put_line('smallest number is'||small);
end;
Output:
largest number is15
smallest number is5
4. Write a PL/SQL program to check whether a number is prime or not?
Program:
declare
a number:=&a;
c number:=0;
i number;
begin
for i in 1..a loop
if mod(a,i)=0 then
c:=c+1;
end if;
end loop;
if c=2 then
113 | P a g e
dbms_output.put_line('number is prime');
else
dbms_output.put_line('number is not prime');
end if;
end;
Output:
Enter value for a: 7
old 2: a number:=&a;
new 2: a number:=7;
number is prime
5. Write a PL/SQL program to check whether a number is palindrome or
not?
Program:
declare
a number:=&a;
c number:=a;
r number:=0;
s number:=0;
begin
while a>0 loop
r:=mod(a,10);
s:=s*10+r;
a:=floor(a/10);
end loop;
if s=c then
dbms_output.put_line('number is palindrome');
else
dbms_output.put_line('number is not palindrome');
end if;
end;
Output:
Enter value for a: 123
old 2: a number:=&a;
new 2: a number:=123;
number is not palindrome
6. Write a PL/SQL program to show handling of Pre-defined exception
Program:
declare
a number:=4;
c number;
114 | P a g e
begin
c:=a/0;
exception
when ZERO_DIVIDE then
dbms_output.put_line('divide by zero exception');
end;
Output:
divide by zero exception
7. Write a PL/SQL program to show handling of User-defined exception
Program:
declare
a number(2);
b number(2);
c number(2);
ex exception;
begin
a:=&a;
b:=&b;
if(b=0) then
raise ex;
else
c:=a/b;
dbms_output.put_line(c);
end if;
exception
when ex then
dbms_output.put_line('divide by zero');
end;
Output:
old 8: b:=&b;
new 8: b:=0;
divide by zero
8. Write a PL/SQL program to print the following values
0 if a=0
1 if a>0
-1 if a<0
Program:
declare
a number:=&a;
begin
115 | P a g e
if a=0 then
dbms_output.put_line('0');
elsif a>0 then
dbms_output.put_line('1');
else
dbms_output.put_line('-1');
end if;
end;
Output:
Enter value for a: 5
old 2: a number:=&a;
new 2: a number:=5;
1
9. Write a PL/SQL program to find even numbers and odd numbers in a
given range m to n
Program:
declare
m number:=&m;
n number:=&n;
i number;
begin
for i in m..n loop
if mod(i,2)=1 then
dbms_output.put_line(i||' is odd number');
else
dbms_output.put_line(i||' is even number');
end if;
end loop;
end;
Output: Enter value for a: 25
old 2: m number:=&m;
new 2: m number:=25;
Enter value for a: 30
old 3: n number:=&n;
new 3: n number:=30;
25 is odd number
26 is even number
27 is odd number
28 is even number
29 is odd number
116 | P a g e
30 is even number
10. Write a PL/SQL program to find armstrong numbers in a given range m
to n
Program:
declare
m number:=&m;
n number:=&n;
i number;
c number;
r number;
s number:=0;
begin
for i in m..n loop
c:=i;
while c>0 loop
r:=mod(c,10);
s:=s+(r*r*r);
c:=floor(c/10);
end loop;
if s=i then
dbms_output.put_line(i||' is armstrong');
end if;
s:=0;
end loop;
end;
Output:
Enter value for m: 150
old 2: m number:=&m;
new 2: m number:=150;
Enter value for n: 1000
old 3: n number:=&n;
new 3: n number:=1000;
153 is armstrong
370 is armstrong
371is armstrong
407 is armstrong
11. Write a PL/SQL program to retrieve records from the sailors table using
cursor
Program:
declare
117 | P a g e
s_id number(2);
s_name varchar2(20);
s_rating number(2);
s_age number(3,1);
cursor c_sailors is select sid,sname,rating,age from sailors;
begin
open c_sailors;
loop
fetch c_sailors into s_id,s_name,s_rating,s_age;
dbms_output.put_line(s_id||' '||s_name||' '||s_rating||' '||s_age);
exit when c_sailors%notfound;
end loop;
close c_sailors;
end;
Output:
22 dustin 7 45
29 brutus 1 33
31 lubber 8 55.5
32 andy 8 25.5
58 rusty 10 35
64 horatio 7 35
71 zorba 10 16
74 horatio 9 35
85 art 3 25.5
95 bob 3 63.5
12. Write a PL/SQL procedure to find factorial of a given number
Procedure:
create or replace procedure fact(n in number, r out number) is
i number:=n; --Never modify in parameter value
f number:=1;
begin
while(i>1) loop
f:=f*i;
i:=i-1;
end loop;
r:=f; --Assign final value to out parameter
end fact;
Output:
Procedure created.
Program:
118 | P a g e
declare
n number;
r number;
begin
n:=&n;
fact(n,r);
dbms_output.put_line('Factorial of '||n||' is '||r);
end;
Output:
Enter value for n: 6
old 5: n:=&n;
new 5: n:=6;
Factorial of 6 is 720
13. Write a PL/SQL procedure to print first n Fibonacci numbers
Procedure:
create or replace procedure fibonacci(n in number) is
f1 number:=0;
f2 number:=1;
f3 number;
i number:=1;
begin
dbms_output.put_line('Fibonacci Series is ');
dbms_output.put_line(f1);
dbms_output.put_line(f2);
while(i<n-1) loop
f3:=f1+f2;
f1:=f2;
f2:=f3;
i:=i+1;
dbms_output.put_line(f3);
end loop;
end fibonacci;
Output:
Procedure created.
Program:
declare
n number;
begin
n:=&n;
fibonacci(n);
119 | P a g e
end;
Output:
Enter value for n: 5
old 4: n:=&n;
new 4: n:=5;
Fibonacci Series is
0
1
1
2
3
14. Write a PL/SQL function to find sum of digits of a number
Function:
create or replace function sumofn(n in number) return number is
s number:=0;
i number:=n;
begin
while(i!=0) loop
s:=s+mod(i,10);
i:=floor(i/10); --Extract decimal part
end loop;
return s;
end sumofn;
Output:
Function created.
Program:
declare
n number;
r number;
begin
n:=&n;
r:=sumofn(n);
dbms_output.put_line('Sum of '||n||' digits is '||r);
end;
Output:
Enter value for n: 456
old 5: n:=&n;
new 5: n:=456;
Sum of 456 digits is 15
15. Write a PL/SQL recursive function to find factorial of a number
120 | P a g e
Procedure:
create or replace function rfact(n in number) return number is
f number:=1;
begin
if n=1 then
return 1;
else
f:=n*rfact(n-1);
return f;
end if;
end;
Output:
Function created
Query;
declare
n number;
r number;
begin
n:=&n;
r:=rfact(n);
dbms_output.put_line('Factorial of '||n||' is '||r);
end;
Output:
Enter value for n: 7
old 5: n:=&n;
new 5: n:=7;
Factorial of 7 is 5040
16. Explain Packages with PL/SQL program
Package Specification:
CREATE OR REPLACE PACKAGE DEMO AS
-- Function Specs goes here
FUNCTION fact(n in number) return number;
-- Procedure one specs goes here
PROCEDURE circle(radius in number, area out number, cir out number);
END DEMO;
Output:
Package created.
Package Body:
CREATE OR REPLACE PACKAGE BODY DEMO AS
FUNCTION fact (n in number) return number is
121 | P a g e
pno number(3):= 0;
c number:= 1;
BEGIN
pno:= n;
WHILE pno >= 1
Loop
c:= c * pno;
pno:= pno - 1;
END LOOP;
return c;
END fact;
PROCEDURE circle (radius in number, area out number, cir out number) AS
BEGIN
area:= (22/7) * radius * radius;
cir:= 2* (22/7) * radius;
END CIRCLE;
END DEMO;
Output:
Package body created.
Program:
DECLARE
x1 number:= 2; -- radius
f1 number:= 5; -- fact
x number:= 0;
sa number:= 0;
sb number:= 0;
BEGIN
x:= demo.FACT(f1);
dbms_output.put_line('Factorial of '||f1||' is '||x);
demo.CIRCLE(x1,sa,sb);
dbms_output.put_line('Area is '||sa||' '||'Circumference is '||sb);
END;
Output:
Factorial of 5 is 120
Area is 12.57142857142857142857142857142857142856
Circumference is 12.57142857142857142857142857142857142856
122 | P a g e
(Approved by AICTE & GOVT OF A.P and Affiliated to JNTU)
Yamnampet, Ghatkesar, Hyderabad – 501 301
LABORATORY MANUAL
FOR
DEPARTMENT OF
ELECTRONICS AND COMPUTER ENGINEERING (ECM)
February 2024
123 | P a g e
VISION OF THE DEPARTMENT
To emerge as a premier centre in Electronics and Computer engineering with focus on human
values and professional ethics
124 | P a g e
Program Outcomes (POs)
125 | P a g e
Program Specific Outcomes (PSO)
126 | P a g e
LAB MANUAL ANALOG AND PULSE CIRCUITS (9D461)
L T P/D C
- - 3 1.5
Course Outcomes:
At the end of the laboratory course, the students will be able to
1. To understand the design and working of various linear and non-linear wave shaping circuits.
2. To demonstrate the working principle of various multivibrators.
3. To verify the functionalities of various logic gates.
4. To perform and verify the BJT/ FET and feedback amplifiers.
5. To perform and verify the working of oscillators and voltage regulators.
6. To perform laboratory experiment to verify the conversion efficiency of various power
amplifiers.
Mapping of Course Outcomes with Program Outcomes
7.
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO PO PS PS PS
11 12 O1 O2 O3
CO1 3 3 3 2 2 2 3 2
CO2 3 3 3 2 2 2 3 2
CO3 2 3 3 2 2 2 3 2
CO4 3 3 3 2 2 2 3 2
CO5 2 3 3 2 2 2 3 2
CO6 3 3 3 2 2 2 3 2
Ove
3 3 3 2 2 2 3 2
rall
127 | P a g e
Syllabus Content:
Part-A: Hardware based experiments
1. Linear wave shaping.
2. Non Linear wave shaping – Clippers. clampers.
3. UJT Relaxation Oscillator
4. Astable and monostable Multivibrator.
5. Bistable Multivibrator.
6. Study of Logic Gates with discrete components.
128 | P a g e
Contents
S.No: Name of the Experiment Page No
CYCLE - I
1 Linear Wave Shaping 136
2 Non Linear Wave Shaping Clipper Circuits 144
3 Non Linear Wave Shaping Clamper 153
4 Study Of Logic Gates 158
5 Astable Multivibrator 163
6 Monostable Multivibrator 166
7 Bi Stable Multivibrator 169
8 UJT Relaxation Oscillator 171
CYCLE – II
129 | P a g e
1. LINEAR WAVE SHAPING
AIM: To understand linear wave shaping using RC high pass and Low pass circuits.
APPARATUS:
1. Bread Board
2. Resistor- 1KΩ-1No.
3. Regulated power supply
4. capacitors- 0.01μf – 1 No.
5. Connecting wires.
6. Function Generator.
7. CRO Probes
8. CRO
CIRCUIT DIAGRAM:
i) High pass circuit:
130 | P a g e
THEORY:
The linear wave shaping circuits alter the shape of a waveform by passing them though a
process of differentiation or integration. High pass circuits allow high frequency signals and
attenuate low frequency signals. High pass circuits acts as a good differentiator for RC<<T. Low
pass circuits allows low frequency signals and attenuates high frequency signals. Low pass
circuits acts as a good Integrator for RC>>T.
PROCEDURE:
131 | P a g e
EXPECTED WAVEFORM:
132 | P a g e
Out put wave forms: High Pass RC Circuit
133 | P a g e
THEORITICAL CALCULATIONS:
High pass circuit:
RESULT:
Linear wave shaping using RC high pass and Low pass circuits is studied.
VIVA-QUESTIONS:
Ans: A linear network is a network made up of linear elements only.The principle of superposi-
tion and the principle of homogeneity hold good for linear networks.
Linear wave shaping: it is the process whereby the form of non sinusoidal signal is altered by
transmission through a linear network.
Ans: The time constant of a circuit is defined as the time taken but the output to rise to 63.2% of
the amplitude of the input step T = RC.
3. Define %Tilt and Rise Time. Write the expressions for the same.
Ans: %Tilt: %Tilt is defined as decay in the amplitude of the outut voltage wave due to the inut
voltage maintaining constant level.
Rise Time: The rise time t is defined as the time taken by the output voltage waveform of a
low pass circuit excited by a step input to the rise from 10% to 90% of its final value.
The rise time of the output of a low pass circuit excited by a step input is given by
4. When High pass RC circuit is used as Differentiator? What is the formula for the output, when
operated as differentiator?
134 | P a g e
Ans: The high pass RC circuit acts as a differentiator provided the RC time constant of the cir-
cuit is very small in comparison with the time required for the input signals to make an apprecia-
ble change.
Vo (t) = RC dvi(t) / dt
5. When Low pass RC circuit is used as Integrator? What is the formula for the output, when the
circuit is operated as Integrator?
Ans: If the time constant of an RC low pass circuit is very large in comparison with the time re-
quired for the input signal to make an appreciable change, the circuit acts as an integrator.
Vo (t) = t2 / 2RC
6. What is the Difference between Low pass and High pass RC circuits.
Ans: Low Pass: A Low pass circuit is a circuit which transmits only low frequency signals and
attenuates or stops high frequency signals.
High Pass: A High pass circuit is a circuit which transmits only high frequency signals and at-
tenuates or stops low frequency signals.
7. A Capacitor blocks __ signal and passes __ signal. The voltage across the ___ will not change
suddenly.
Ans: A Capacitor blocks DC signal and passes AC signal. The voltage across the capacitor will
not change suddenly.
Ans:
High Pass
Low Pass
9. A differentiator converts a square wave into what form? An integrator converts a square wave
into what form?
Ans: A differentiator converts a square wave into spikes waveform An integrator converts a
square wave into triangle waveform.
135 | P a g e
10. What are the formulae for charging a capacitor from an initial voltage of Vi to a final voltage
of Vo.
11. Instead of using RC components for a low pass or high pass, how the circuit changes , if we
want to use RL components? What are the values for the Time constant for RL circuits?
Ans: T = L/R
12. When a capacitor in a low pass circuit charges to 99.3 % ( treated as fully charged) for a step
input to a Low pass filter?
Ans: V0 = Vi
Ans: The process of converting pulse into pips by means of a circuit of very short time constant
is called peaking.
Ans: A ringing circuit is a circuit which can proved as nearly and un-damped oscillations as pos-
sible.
Ans: A resistive alternator needs to be compensated in order to reduce or eliminate the rise time
of the output waveform.
Design Problems:
i. RC = 5T
ii. RC = T
iii. RC = T/5
1. Verify the output of circuits given in Fig1.1 and Fig 1.2 for input square wave of fre-
quencies 10KHz and 500Hz.
2. Verify the RC high pass circuit output for sinusoidal input.
136 | P a g e
2. NON LINEAR WAVE SHAPING CLIPPER CIRCUITS
APPARATUS:
1. Bread Board
2. CRO Probes
3. CRO
4. Capacitor- 0.1μf
5. Regulated power supply
6. IN 4007 diode-1No.
7. Connecting wires.
8. Function Generator.
Circuit diagrams:
Input Signal
Transfer characteristics:
137 | P a g e
Positive clipper with zero reference (Series clipper):
Transfer characteristics:
138 | P a g e
Negative clipper with zero reference (Shunt clipper):
Transfer characteristics:
139 | P a g e
Transfer characteristics:
140 | P a g e
Transfer characteristics:
141 | P a g e
Transfer characteristics:
142 | P a g e
Transfer characteristics:
Transfer characteristics:
THEORY:
Clipping circuits are commonly realized with diodes and resistor and do not contain any energy
storing components. The function performed by the clipping circuits essentially either limiting or
slicing. These circuits also employ devices such as diodes, Zener diodes, and transistors along
143 | P a g e
with resistors. Amplitude selectors and Amplitude limiters are the other names of the clipping
circuits
PROCEDURE:
1. Connect the circuits as per the circuit diagram
2. Connect the CRO Ch-I to input and Ch-2II to output of the circuit.
3. Adjust the input sine wave amplitude to 5V P-P.
4. Connect the D.C.battery wherever necessary.
5. Observe the wave form in the CRO channel II and not the waveform.
RESULT: Diode clipper circuit using ordinary and Zener Diode are studied and observed the
waveforms.
VIVA-QUESTIONS:
1. Define non linear wave shaping? What are the non-linear components?
Ans: The circuits for which the outputs are non-sinusoidal for sinusoidal inputs are called non-
linear wave shaping.
2. Define clipping circuit? What are the other names for clippers?
Ans: A clipping circuit is a circuit which removes the undesired part of the waveform and trans-
mits only the desired part of the signal which is above or below some particular reference level.
The other names for clippers are voltage (or current), limiters, amplitude, selectors or slicers.
Ans: The piecewise linear approximation of a semi conductor diode the break down is at V
which is called offset or threshold voltage the diode behaves like an open circuit if v < V . The
characteristics show a constant incremental resistance r = dv / di if v > V .
144 | P a g e
6. Emitter Coupled Clippers
Ans: Two level clipper [It clips both positive and negative peaks]
Ans: Clipping circuits may be used to convert sine waves into square waves. They may also be
used to remove unwanted noise signals
Ans: The ratio of Rr / Rf is a figure of merit for diodes using in clipping circuit .
8. What is the influence of the practical diode compared to the ideal diode, in the above circuits?
Ans: In ideal diode current flows freely through the device , when forward bias having no
ressistance . a practical diode offers some in resistance to current flow when it is forward bias an
9. Instead of sinusoidal wave form as input, if we give other wave forms like triangular or
square, then how the clipping action is performed?
145 | P a g e
3. NON LINEAR WAVE SHAPING CLAMPER
APPARATUS:
1. Bread Board
2. Patch cards
3. CRO Probes
4. CRO
5. Resistor- 1KΩ-1No.
6. Regulated power supply
7. IN 4007 diode-1No.
8. BZX6V2 diode- 2 No.
9. Connecting wires.
10. Function Generator.
CIRCUIT DIAGRAM:
Input Signal
146 | P a g e
Fig.3.3 Negative clamping with Negative reference voltage
THEORY:
147 | P a g e
Clamping circuits do not make any effort to change the wave shape of any signal. Their
main concern is to introduce a dc shift into a waveform by altering its dc component. In RC
coupling and capacitive coupling, the blocking capacitor does not allow the dc component of the
applied signal to pass through it. Since all the sinusoidal components pass through the blocking
capacitor, the wave shape of the signal remains the same after transmission while its dc level is
brought down to zero. Clamping circuits are essentially used to restore this lost dc component.
The process where sinusoidal signals are going to be altered by transmitting through a non-lin-
ear network is called non-linear wave shaping. Non-linear elements (like diodes) in combination
with resistors and capacitors can function as clamping circuit.
i. Negative Clampers
ii. Positive Clampers
148 | P a g e
PROCEDURE:
1. Connect the circuits as per the circuit diagram
2. Connect the CRO Ch-I to input and Ch-2II to output of the circuit.
3. Adjust the input sine wave amplitude to 5V P-P.
4. For Zener diode clipper, increase the amplitude of the input Wave form to 15V P-P
5. Observe the wave form in the CRO, with and without connecting the D.C.battery (i.e. biasing)
and note the wave form from Ch-II of CRO.
VIVA-QUESTIONS:
1. What are the applications of clamping circuits?
Ans: Clapping circuits are used to fix the positive or negative extremity of a periodic waveform
at some constant reference level.
Ans: When a signal is transmitted to a capacitive coupling network (RC high pass circuit), it
losses its dc component, and a clamping circuit may be used to introduce a dc component by fix-
ing the positive or negative extremity of that waveform to some reference level.
Ans: The clamping circuit theorem state that for any input waveform under steady state condi-
tions, the ratio of area Af under the output voltage curve in the forward direction to that in the re-
verse direction Ar is equal to the ratio Rf / R, i.e., Af / Ar = Rf / R
Ans: The function of capacitor in clamper circuit is that it will add dc signal to the ac signal.
6. What are the effects of diode characteristics on the output of the Clamper?
Ans: When temperature varies reverse saturation current increases and cut in voltage decreases
which effects clamping circuit.
7. If we interchange the diode and the capacitor in fig 1 above, how the circuit behaves?
Ans: If capacitor connected in series to allow AC ,for DC allowing circuits capacitors connected
in parallel.
8. Calculate the power dissipation in the Resistor for any one of the above circuits?
149 | P a g e
9. What is the difference between a clipper and a clamper?
Ans: Clipper clips OFF the unwanted portion of the input waveform, and the clamper simply
clams the maximum positive or negative peak to a desired level.
Ans: The other names for clampers are: Dc restorer and Dc reinserter
150 | P a g e
4. LOGIC GATES
AIM: To study and verify the truth table of AND, NOR, OR, NOT, NAND Gate (Discrete
version)
APPARATUS:
1. Bread Board
2. IC trainer Kit Patch cards
3. Diodes IN4007
4. Resistors (1kΩ, 100Ω, 4.7kΩ, 330Ω, 10KΩ)
5. Capacitors (0.1μf)
4. Connecting wires.
CIRCUIT DIAGRAM:
151 | P a g e
152 | P a g e
153 | P a g e
154 | P a g e
155 | P a g e
THEORY:
In digital electronics, the binary digits 0 and 1 are represented by voltages LOW and HIGH.
This branch of electronics is mathematically supported by Boolean algebra. The basic logic
operations in this algebra are NOT, AND & OR. These logic operators are binary as they work
on two operands to specify the output.
PROCEDURE:
1. Connect the circuit as per the circuit diagram.
2. Give different combinations of inputs and observe the output.
3. Construct the truth tables for each circuit considering the input and output levels of the circuit.
RESULT: The truth tables of AND, OR, NOT, NOR, NAND gates are verified.
VIVA-QUESTIONS:
1) What is logic gate and by using which devices we can realize the logic gates?
2) What is combination circuit? What is truth table?
3) Realize the NAND gate using AND,OR and NOT gates?
4) Realize logic gates using transistors?
5) What is IC and give some IC’s name for logic gates?
156 | P a g e
5. ASTABLE MULTIVIBRATOR
AIM: To study an Astable Multivibrator to generate a square wave using Astable multivibrator.
APPARATUS:
1. D.C. Regulated power supply
2. Dual Trace CRO
3. Resistors
4. Capacitors/Decade capacitance box.
5. Bread Board.
CIRCUIT DIAGRAM:
THEORY:
Transistor multivibrators make use of all the three regions of operations: cut-off, saturation, as
well as the active region. The working principle of transistor multivibrators involves the cutoff
and saturation regions. Astable multivibrator can also be treated as a relaxation oscillator. The
astable multivibrator has two quasi-stable states. This circuit is commonly used for the
generation of a rectangular waveform.
157 | P a g e
PROCEDURE:
1. Connect the circuit diagram according to the given diagram.
2. Apply D.C.power supply to the circuit.
3. Observe the base and collector voltages of Q1 and Q2 on CRO.
4. Measure the time period of the output waveforms and compare with theoretical
Values.
5. Repast the above steps with different capacitance values from decade capacitance.
158 | P a g e
THEORITICAL CALCULATIONS:
T=0.69 (RB1C1+RB2C2)
RESULT:
The working of Astable multivibrator is studied and Observed the practical values and
waveforms.
VIVA-QUESTIONS:
159 | P a g e
6. MONOSTABLE MULTIVIBRATOR
APPARATUS:
1. D.C. Regulated power supply
2. Dual Trace CRO
3. Resistors
4. Capacitors/Decade capacitance box.
5. Bread Board.
CIRCUIT DIAGRAM:
160 | P a g e
THEORY:
PROCEDURE:
1. Connect the circuit diagram according to the given diagram.
2. Apply D.C.power supply to the circuit.
3. Observe the base and collector voltages of Q1 and Q2 on CRO.
4. Measure the time period of the output waveforms and compare with theoretical
Values.
5. Repeat the above steps with different capacitance values from decade capacitance.
161 | P a g e
THEORITICAL CALCULATIONS:
RESULT: The working of Mono stable multivibrator is studied and Observed the practical
values and waveforms.
162 | P a g e
7. BI STABLE MULTIVIBRATOR
APPARATUS:
1. D.C. Regulated power supply
2. Dual Trace CRO
3. Resistors
4. Capacitors/Decade capacitance box.
5. Bread Board.
CIRCUIT DIAGRAM:
THEORY:
The Bistable Multivibrator is another type of two state device similar to the monostable
multivibrator. Bistable Multivibrators have TWO stable states (hence the name: "Bi" meaning
two) and maintain a given output state indefinitely unless an external trigger is applied. The
bistable multivibrator can be switched over from one stable state to the other by the application
of an external trigger pulse thus, it requires two external trigger pulses before it returns back to
its original state. As bistable multivibrators have two stable states they are more commonly
known as Latches and Flip-flops for use in sequential type circuits.
163 | P a g e
PROCEDURE:
RESULT: The working of Bistable multivibrator is studied and Observed the practical values
and waveforms.
VIVA-QUESTIONS:
164 | P a g e
8. UJT RELAXATION OSCILLATOR
APPARATUS:
1. Bread Board
2. Patch cords
3. CRO
4. CRO Probes
5. Components, UJT
THEORY:
Uni junction transistor has only one junction. It is used to generate saw tooth wave forms i.e.
time base signals. UJT is used as a relaxation oscillator. A relaxation oscillator is one which
gives saw tooth waveforms without giving any input signal.
CIRCUIT DIAGRAM:
165 | P a g e
EXPECTED WAVEFORM:
PROCEDURE:
1. Connect the circuit as per the diagram
2. Switch on the supply and the capacitor is taken across the capacitor Ce.
3. Observe the output waveform and calculate the time period.
RESULT:
The UJT relaxation oscillator is studied.
VIVA-QUESTIONS:
1) What is an oscillator?
2) What is relaxation oscillator?
3) What are the different methods are used to generate time base waveforms?
4) What are the applications of relaxation oscillator?
5) What are differences between diode and UJT?
166 | P a g e
CYCLE -II
167 | P a g e
Experiment No. 1
AIM: To measure the gain, bandwidth, input resistance, output resistance of CE amplifier by
using TINA software
APPARATUS:
TINA software.
CIRCUIT DIAGRAM:
V1 12V
R1 3 .3 k
R3 3 3k
C1 10uF VF1
R2 1k C1 10uF
T2 BC107A
R1 4 .7 k
C1 1 00 uF
+
R1 4 70
VG1
168 | P a g e
EXPECTED GRAPH :
169 | P a g e
170 | P a g e
PROCEDURE ( FREQUENCY RESPONSE ):
QUESTIONS:
1. Does phase reversal exist in CE amplifier?
2. Does phase reversal effect amplification?
3. What is signification of operating point?
4. Mention the influence of coupling capacitor CC on low frequency response.
5. Define & .
6. Calculate with the help of observed in this experiment?
7. In which transistor configuration current gain is less than unity.
Experiment No. 2
171 | P a g e
COMMON SOURCE AMPLIFIER
AIM: To measure the gain, bandwidth, input resistance, output resistance of CS amplifier by us-
ing TINA software.
APPARATUS:
TINA software.
CIRCUIT DIAGRAM:
V1 12V
R1 4 .7 k
C1 10uF VF1
R2 1k C1 10uF
C1 1 00 uF
T1 BF245A
R1 2 .2 M
+
R1 4 70
VG1
EXPECTED GRAPH :
172 | P a g e
PROCEDURE( FREQUENCY RESPONSE ):
CALCULATIONS:
QUESTIONS:
173 | P a g e
Experiment No.3
TWO STAGE RC COUPLED AMPLIFIER
AIM: To meaure and plot gain and bandwidth (frequency response) for two stage RC coupled ampli-
fier by using SPICE software.
APPARATUS :
CIRCUIT DIAGRAM:
R1 3 .3 k
R1 3 3k
R1 3 .3 k
C110u VF1
VF2
R21k C110u
C110u
T1 BC107
T2 BC107
R1 4 .7 k
R1 4 .7 k
+
C1 1 00 u
VG1
R1 4 70
C1 1 00 u
R3 1 0k
R1 4 70
THEORY:
The output from single stage amplifier is usually insufficient to drive to drive an output
device. To achieve the extra gain the output of each amplifier stage is coupled in some way to
the input of next stage. A transistor circuit contains more than one stages known as multistage
amplifier.The coupling of one stage to another is done with help of some coupling device. If is
coupled with R and C then the amplifier(cascade) is called
R-C coupled amplifier. It can be Direct coupled or transformer coupled.
GAIN:- The gain G is the ratio of output to input. The gain of the multistage amplifier is equal to
the product of gains of individual stages.
i.e G=G1 x G2 x G3.
174 | P a g e
(EXPECTED GRAPH):-
CALCULATIONS:
Single stage:
175 | P a g e
Two Stage:
QUESTIONS:
1. Is fH* for two stages greater or smaller than fH for a single stage? Explain
2. Given an approximate expression relating fH* and 3-dB frequencies of n
non-identical stages?
3. Three identical cascaded stages have an overall upper – 3dB frequency of 20 KHZ and a
lower 3-dB frequency of 20HZ. What are fL and fH of each stage? Assuming non-inter-
acting stages?
4. R-C coupled amplifier has a very ______ frequency response curve.
5. Direct coupling is used for amplifying _______________________.
176 | P a g e
Experiment No:4
AIM: To calculate the input resistance of Darlington pair and comparing with the theoretical
values.
APPARATUS:
SPICE Software
CIRCUIT DIAGRAM:
R6 1 00 M
T1 BC107
R11k C110uF
VF2
R3 3 3M
C210uF
T2 BC107
R7 3 3M
C310uF VF1
+
R4 5 00
VG1
R5 1 0k
PROCEDURE:
1. Connect the circuit diagram as shown in Fig.
2. Calculate the input resistance by the following for both stages
And compare with the theoretical values
Observation:
Result:
177 | P a g e
Experiment No.5
AIM: To measure the gain and bandwidth (frequency response) of voltage shunt feedback amplifier
with and without feedback by using TINA software.
APPARATUS:
TINA Software
CIRCUIT BIAGRAM;
EXPECTED GRAPH :
178 | P a g e
PROCEDURE:
CALCULATIONS:
179 | P a g e
4. Upper cutoff frequency = fH1.
5. 3-dB band width of the amplifier = fH1 - fL1..
180 | P a g e
Experiment No.: 6
APPARATUS:
CIRCUIT DIAGRAM
EXPECTED GRAPH
181 | P a g e
PROCEDURE:
f0 = for : C = 0.01 F
R = 2.7 K
182 | P a g e
Experiment No: 7
AIM: To determine the efficiency of Class A power amplifier using TINA software.
APPARATUS:
INTRODUCTION:
In almost all electronic systems, the last stage has to be a power amplifier. For example, in a
public-address system, it is the power amplifier that drives the loud speakers. A power amplifier
is meant to boost the power level of the input signal. This amplifier can feed a large amount of
power to the load. To obtain large power at the output of the power amplifier, its input- signal
voltage must be large. That is why, in an electronic system, a voltage amplifier invariably
proceeds the power amplifier. Therefore, the power amplifiers are called large-signal amplifiers.
Actually the power amplifier does not amplify the power. The power amplifier takes power from
the dc power supply connected to the output circuit and converts it into useful ac signal power.
This power is fed to the load (e.g. loud speaker).
The type of ac power developed at the output of the power amplifier is controlled by the input
signal. Thus, a power amplifier is also called as a dc- to-ac power converter, whose action is
controlled by the input signal.
Power amplifiers are divided into many types depending their conduction time over a cycle.
They are
CIRCUIT DIAGRAM:
183 | P a g e
EXPECTED GRAPH:-
184 | P a g e
THEORY:
In Class-A operation, the transistor stays in the active region through- out the ac cycle. In this
operation, the transistor conducts for full 360° of the input cycle. For making conduction
possible through 360°, that is, through both positive and negative half-cycles, it is necessary that
the transistor should be biased for swing in the negative half-cycle also. Such biasing causes
continuous drain of current from the power-supply or battery, even if the input signal is absent. '
The output signal varies for a full (3600) cycle of the input. In this case, the Q-point is biased al -
most at the half of the DC load line. A Class-A amplifier, with DC bias at one half of the supply
voltage, uses a good amount of power to maintain bias, even with no signal applied. This results
in very poor efficiency. When very little AC power is delivered to the load a large amount of
power is dissipated in the collector resistance (Rc). This results in a maxi- mum efficiency of
only 25%. By replacing the collector resistance (Rc) by a large inductor (also called a choke), the
maximum efficiency can be increased to 50%.
PROCEDURE:
185 | P a g e
Experiment No: 8
AIM:
To study Class-B (complementary Symmetry) power amplifier and to determine its efficiency
and simulate the same using spice / TINAPRO Software.
APPARATUS:
INTRODUCTION:
In almost all electronic systems, the last stage has to be a power amplifier. For example, in a
public-address system, it is the power amplifier that drives the loud speakers. A power amplifier
is meant to boost the power level of the input signal. This amplifier can feed a large amount of
power to the load. To obtain large power at the output of the power amplifier, its input- signal
voltage must be large. That is why, in an electronic system, a voltage amplifier invariably
precedes the power amplifier. Therefore, the power amplifiers are called large-signal amplifiers.
Actually the power amplifier does not amplify the power. The power amplifier takes power from
the dc power supply connected to the output circuit and converts it into useful ac signal power.
This power is fed to the load (e.g. loud speaker).
The type of ac power developed at the output of the power amplifier is controlled by the input
signal. Thus, a power amplifier is also called as a dc- to-ac power converter, whose action is
controlled by the input signal.
Power amplifiers are divided into many types depending their conduction time over a cycle.
They are
186 | P a g e
CIRCUIT DIAGRAM:
EXPECTED GRAPH :
187 | P a g e
THEORY:
The circuit of class-B push-pull amplifier uses two transformers, one at the input and cone at the
output. However, transformers are costly and add to the weight of the amplifier. We can elimi-
nate this drawback by using class- B complementary -symmetry power amplifier. This amplifier
does not have any transformer.
This circuit uses a pair of transistors having complementary symmetry,; that is, one transistor is
PNP and the other is NPN. The complementary- symmetry circuit requires two power supplies,
since each transistor must be biased suitably. The resistors act as voltage dividers across power
supplies to forward bias the emitter-base junction of both transistors. The transistors are operated
in Class-B. That is the bias is adjusted such that the operating point corresponds to the cut-off
points. Hence, with no signal input, both transistors are cut-off and no collector current flows.
The signal applied at the input goes to the base of both the transistors. Since the transistors are of
opposite type, they conduct in opposite half-cycles of the input. For example, during the positive
half-cycle of the input signal, the PNP transistor is reverse biased and does not conduct. The
NPN transistor, on the other hand is forward-biased and conducts. This results in a half-cycle of
output voltage across the load resistor. The other half-cycle of output across the load is provided
by the conduction of other transistor dur -ing the negative half-cycle of the input. Since the
collector current from each transistor flows through the load during alternative half-cycles of the
input signal, no centre tapped output transformer is required.
The two transistors-though of opposite type, must be matched. If there is an imbalance in the
characteristics of the two transistors, even harmonics will no longer be cancelled. This would
result in considerable distortion. In- creasing availability of complementary transistors is making
the use of class- B transformer-coupled stages obsolete. All modern power amplifier circuits are
transformer less aid use complementary transistors.
CIRCUIT DESCRIPTION:
ADVANTAGES:
1. This circuit does not require transformer. This saves on weight and cost.
2. The efficiency of Class-B(78.5%) is higher than class -A (50%).
3. Since the efficiency is higher, it is possible to obtain greater power out- put.
188 | P a g e
4. Since the power loss is negligible at no signal condition, it is well suited for battery or solar-
cell operation.
DISADVANTAGES:
1. It is difficult to get both transistors (NPN & PNP) consists of similar characteristics.
2. Both positive and negative supply voltages are required.
3. Cross-over distortion is present.
4. Harmonic distortion is high compared to Class-A.
PROCEDURE:
6. Simulate the above circuit using TINA and compare the both Hardware and simulation
results.
189 | P a g e
Experiment No.9
AIM: To study the Load and Line regulation characteristics of series and shunt voltage
Regulatro
APPARATUS:
TINA software.
THEORY:
A voltage regulator is designed to automatically ‘regulate’ voltage level. It basically steps down
the input voltage to the desired level and keeps that in that same level during the supply. This
makes sure that even when a load is applied the voltage doesn’t drop.
190 | P a g e
Shunt Voltage Regulator
Block diagram
Circuit diagram
191 | P a g e
The voltage drop across series resistance depends upon the current supplied to the load RL. The
output voltage is equal to the sum of zener voltage (VZ) and transistor base-emitter voltage
(VBE)
Vout = VZ + VBE
If the load resistance decreases, the current through base of transistor decreases. As a result, less
collector current is shunted. Therefore, the load current becomes larger, thereby maintaining the
regulated voltage across the load. Reverse happens should the load resistance increase.
Drawbacks:
A large portion of the total current through RS flows through transistor rather than to the
load.
There is considerable power loss in RS.
There are problems of overvoltage protection in this circuit.
For these reasons, a series voltage regulator is preferred over the shunt voltage regulator.
Expected Graphs:
192 | P a g e
Procedure:
Load Regulation:
Where:
VNL = the no-load output voltage
VFL = the full-load output voltage
Line Reulation;
Block diagram
193 | P a g e
Circuit diagram
You can see in the figure that the load current is passing through the series transistor Q1 & that’s
the reason why we call the circuit a series voltage regulator. You can see that we feed the unreg -
ulated d.c. supply through the input terminals so that we can get the regulated across the load.
Here, the zener diode is providing the reference voltage.
Operation of Transistor Series Voltage Regulator
The base voltage of transistor Q1 is held to a relatively constant voltage across the Zener diode.
For example, if 8V zener (i.e., VZ = 8V) is used, the base voltage of Q1 will remain approxi-
mately 8V. Hence , Vout = VZ – VBE
194 | P a g e
Case 1 : Output Voltage Decreases
Under this circumstance , the increased base-emitter voltage will cause transistor Q1 to conduct
more, thus increasing the output voltage. Hence, the output voltage will be maintained at a con-
stant level.
Under this circumstance , the decreased base-emitter voltage will cause Q1 to conduct less, thus
reducing the output voltage. Hence, the output voltage will be maintained at a constant level .
EXPECTED GRAPHS:
Procedure:
195 | P a g e
Load Regulation:
Where:VNL = the no-load output voltage; VFL = the full-load output voltage
Line Reulation;
Connect the circuit as shown in fig.
Keep the Load Resistance =10Kohm
Draw the DC characteristic by Vary the inpu voltage 0-20V
196 | P a g e