Document 12 (2)

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

NAME=ANUPAM UPADHYAY

ROLL NUMBER=14

COURSE= BCA

SUBJECT= PROBLEM SOLVING USING


PYTHON
FACULTY=SANJIV AGARWAL
Q1. Write Shorts Notes on
(i) Generation of computer
(ii)Generation of programming
language
Ans(i). There is five generation of
computer from 1940 to 1971 onward
(a).FIRST GENERATION(1940-1956)
TECNOLOGY:Vacuum tubes

Key features:huge size,high electricity,and


limiting processing speed

Memory:Magnetic drums

Ex:UNVIC,ENIAC,EDVAC

(b).SECOND GENERATION(1959-1965):
TECNOLOGY:Transistors

Key features:Smaller,faster,and more reilabe than


first-generation computer

Mermory: Magnetic tapes and Magnetic disks

Ex: PDRD SEP-8,IBM1401,CDC1604

Programming languages: Fortran,cobol,algol

(c).THIRD GENERATION(1965-1971):
TECNOLOGY: Intergrated Circuits(ICs)

Key features : Further size reduction,increased speed


and effciency,better mermory managment,

Mermory: single chip of silicon

Programming language: PL/1,PASCAL,BASIC

Memory:IBM 370,PDP11

(d). FOURTH GENERATION(1971-1980)


Key features: Personal computer,compact,highly
efficient with the use of chips containing thousands of
integrated circiuts

TECNOLOGY:Microprocessors

Mermory: Semiconductor resulting in large random


acess memories

Programing language:UNIX operating system and


Cprogrming lanuages

(e).FIFTH GENERATION(1980 ONWARDS)


TECNOLOGY:Ultra large scale integrated (ULSI)

KEY features:Parallel processing,faster processing


speed ,based on artificial intelligence

Ex : AI-driven, quantum computers

Programing_language:Advanced_programing
language like prolog, python

(ii)GENERATION OF PROGRAMING
LANGUAGE:
1. first generation:

Language type:Machine language

Key features:Written in binary(0s


and1s),directly understood by computers

Usage:computers,low-level,hardware
specific

Ex:Binary code(101101)

2.Second generation:

Language type:Assembly language

Key features: Uses shotcodes or


mnemonics instesd of binary,needs an
assembler to convert to machine language

Usage:General-purpose programming for


applications and software

Ex:C,Java,python
3.Third Generation

Language type:High-level languages

Key Features:Closer to human


languages,easier to read and a write

Usage:General-purpose programing for


application and software

Ex:C,python

4.Fourth Generation

Language type: Declarative languages

Key features:Focuses on what needs to be


done rather than how,abstract and user-
friendly.

Usage:Database_management,reports

Generation

Ex:SQL,MATLAB
5.Fifth Generation

Language_type:AI_and_logic-based
languages

Key feartures:Allows the system to solve


problems on its own

Usage:AI,experts systems,neural networks

Ex:Prolog,lisp

Q2.Explain the different components of


computer

Ans. Main components of computer

1.CPU(central processing unit):

The brain of the computer that processing


data and instruction

2. Memory(RAM)
Tempory storage for data in use;it’s fast but
clear when the computer if off.

3.Storage (Hard drive/ssd)

Long-term storage for file and


programs,retains data even when off

4.Input devices

Tools that takes inputs for processing(e.g;


keyword,mouse)

5.Output devices:

Tools to display or produce


data(e.g;monitor,speakers)

6.GPU(Graphics processing unit)

Handles visual output like images and


videos
Q3: let’s say we have a garden that is 10 mtr
long and 5 mtr wide and we want to
calculate its area and perimeter. Write an
algorithm and draw a flow chart for the
same.

Ans.source code
length=10

width=5

area=length*wide

Perimeter=2*(length+width)

Print(“The area of the gerden is ”,area)

Print(“The perimeter of the gerden


is ”,perimeter)

Algorithm

Step1:start
Step2: input the value of length of garden

Step3: input the value of width of garden

Step4: calculate area=length*width

Step5:calculate_perimeter=2*(length+width
)

Step6: print the area of garden as, area

Step7: print the perimeter of garden


as,perimeter

Step8: Ends

Flow chat of area and perimeter of garden


Q4: Imagine you are organizing a shelf of
books in a library. The books are numbered,
and you realize that two books are out of
order: Book A (with number 5) and Book B
(with number 3). You need to swap their
posions to get them in the correct order.
Write an algorithm and flowchart for the
same.

Ans. Algorithm to swap the positons of two


books
Step1. Start

Step2. Enter the value of first book as,A=5

Step3.Enter the value of second book as,B=3

Step4. Assign the value of A as c=A and


assign the value of Bas B=A

Step5. Assign B=c

Step6. print the value of A

Step7. print the value of B

Step8. Ends
Q5. Write a Python program to calculate
compound interest.

Ans.

princ=float(input(“Enter the principal


amount”))

rate=float(input(“Enter the rate of interest”))

time=float(input(“Enter the time of years”))

n=float(input(“enter the no.of times


interest”))

rate=rate/100

amount=principal*(1+rate/n)**(n*time)

C_I=amount-principal

Print(‘coumpond interset of amount:’,C_I)


Q6: Explain debugging and types of error in
Python.

Ans.Debugging is process of finding and


fixing errors or bugs in the source code of any
software for ensure it for runs correctly

Type of Errors in python.

1.NameErrors: This Error raises when


identifier is not defined

Message: NameError;name’variable_name’
is defined

2. IndexError: this Error that occurs when


python interpeter pares yuor code and find
incorrects code that does not conform

Message:SyntaxError:invalid syntax

3.IndexError: The IndexError is thrown when


trying to access an item at an invalid index.
4.Runtime Error: Happen during executon,
often due to invalid operatons

5.LogicalError: They occurs when the


program runs without crashing,but produces
an incorrect result

Message: No specific error,but output is


wrong

Q7.Design a flowchart and algorithm to


check whether the entered year is a leap
year or not.

Ans. Algorithm to check for a leap year

Step1: start

Step2: Enter the value of Year whose leap


year you want to check as Y

Step3:check(Y%4==0 and (Y%100!=0 or


Y%400==0)) go to step 4
Step4: print leap year ,Y

Step5: print this is not a leap year

Step6: END

Flowchart for cheking a leap year


START

enter the year


asY

(Y%4==0and

(Y%100!=0or Y%400==0)

print ''Y" is a print ''Y" is a


leap year not leap year

END

Q8:Explain the memory hierarchy of a


computer in detail
Ans.Memory Hieracy of a computer

1.Registers: register are small,high-speed


memory units located in the cpu

2.Cache Mermory:Cache memory ,fast


memory unit located close to the cpu. It
stores frequently used data and instruction
that have been recently acessed from the
main memory

3.Main memory: main memory is also know


as RAM ,is the primary memory of a computer
system

4.Secondry_memory:secondry
storage,such as hard disk drives and solid-
state drives is a volatile memory unit that has
a larger storage capacity than main memory.
5.Magnetic Disk: it is the simply circular
plates that are fabricated with either a metal
or a plastic .

6.Magnetic Tap: it is simply a magnetic


recording device that is covered with a
plactic film.It is generally used for the backup
of data.

Q9:Design a flowchart and algorithm to


find greatest between four numbers.

Ans.Algorithm to find the greatest among 4


number

Step1: start
Step2:Enter the four number as A,B,C,D

Step3: Check(A>BandA>CandA>D)if it true


than go to step 4 and if it false go to step5

Step4:PRINT”A”is greastest number


Step5:Check(B>AandB>Cand B>D)if it true
than go to step 6 and if it false go to step 7

Step6: print”B” is greastest number

Step7: Check(C>AandC>Band C>D)if it true


than go to step 8 and if it false go to step 9

Step8: print”C” is greastest number

Step9: print”D” is greastest number

Step10:END

Flowchart for Finding the Greatest


Number:
start

enter value
asA,B,C,D

A>BandA
>CandA>

B>Aand
PRINT B>Cand
A
PRINT D
IS
PRINT B IS
GREASTE
GREASTEST

END

Que 10. Convert the following: i.


(1011.101)2 = ( )10
(ii).(1011101)2 = ()10

(iii)(231)10=() 2

You might also like