0% found this document useful (0 votes)
34 views31 pages

Scientific Calculator

Uploaded by

S. Lakshanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views31 pages

Scientific Calculator

Uploaded by

S. Lakshanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Computer Science Project

Scientific Calculator

NAME: SAMANTHULA LAKSHANYA


CLASS: XII
STREAM: PCM
I would like to express my special thanks of
gratitude to Mr. Dr. R. KRISHNAMOORTHY ,
CHAIRMAN , Sri Krish International School for
providing me with all the facility that was required
to complete my project.

I am thankful to Mrs. Dr. S. UDAYA CHITRA,


PRINCIPAL , Sri Krish International School for
her valuable guidance and for her constant
encouragement.

It gives me great pleasure to extend my special


thanks to my Computer Science teacher Mrs.
KEERTHIKA (PGT COMPUTER SCIENCE) for
her guidance and encouragement throughout the
duration of the project. Without her motivation and
help , the successful completion of this project
would not have been possible.
This is to certify that _____Samanthula Lakshanya
_____, a student of Grade XII has successfully
completed Computer Science project entitled
‘______Scientific Calculator_______’ under the
guidance of Mrs. KEERTHIKA (PGT
COMPUTER SCIENCE) during the academic year
2024-2025 in partial fulfillment of Computer
Science project conducted by AISSCE , New Delhi.

REGISTER NUMBER:

DATE OF SUBMISSION:
S.no Content Page no.
1. Why we use
python?
2. Introduction
3. Scientific calculator
4. Algorithm
5. Source code
6. Output
7. Bibliography
Python is a high-level programming language that's
easy to learn and use, and has many benefits:

 Simple syntax: Python's syntax is intuitive and


easy to read, with no curly brackets to define
code blocks.

 Fewer lines of code: Python requires fewer lines


of code to perform the same task as other
languages.

 Open-source: Python is free and has frequent


updates and releases from the community.

 Large community: Python has a large


community that can help with programming
issues.

 Extensive libraries: Python has a large


ecosystem of libraries and frameworks, such as
Django for web development, Pandas for data
analysis, and Tensor Flow for machine learning.

 Cross-platform compatible: Python is


compatible across multiple platforms.
 Easy to integrate: Python can easily integrate
with existing systems and applications.

 Dynamic typing: Python is a dynamically typed


language, so there's no need to declare variable
types.

 Automatic memory management: Python's


automatic memory management enhances
productivity.
A scientific calculator is a specialized type of
calculator designed to handle advanced
mathematical functions beyond basic arithmetic. It
is widely used in fields like mathematics,
engineering, physics, and chemistry. Here are its
key features:

 Advanced Functions: Includes capabilities for


trigonometry (sin, cos, tan), logarithms (log, ln),
exponents, and roots.

 Complex Calculations: Can solve equations,


handle factorials, permutations, combinations,
and matrix operations.

 Scientific Notation: Supports calculations with


very large or very small numbers using
exponential notation.

 Memory Functions: Allows users to store and


recall results for multi-step calculations.

 Programmability: Some models can execute


user-defined functions or small programs.
A scientific calculator is a handheld device or
digital tool designed to perform advanced
mathematical, scientific, and engineering
calculations. Unlike basic calculators, it offers a
range of functions tailored to complex
computations.
 Advanced Functions:
Trigonometric (sin, cos, tan, and their
inverses).
Exponential (e^x), logarithmic (log, ln), and
root functions.
Factorials, permutations, and combinations.

 Handling Large Numbers:


Scientific notation for very large or small
values.
 Algebraic Calculations:
Solving equations and quadratic roots.
Handling constants like π and e.

 Memory and Multi-Step Operations:


Storing and recalling values during lengthy
calculations.

 Specialized Functions:
Matrix operations, differentiation, and
integration in advanced models.

 Graphing Capability:
Found in higher-end models, useful for
visualizing equations and functions.
1. Calculator :
- Define a function that takes two numbers and
an operator as parameters.
- Use conditional statements to check which
operator is given and perform the corresponding
arithmetic operation on the numbers.
- Return the result of the operation or an error
message if the operator is invalid.
- Use a loop to prompt the user to enter two
numbers and an operator, separated by spaces.
- Call the function with the user input and print
the output.
- Exit the loop if the user enters 'q' or 'quit'..
2. String Reversal :
- Use slicing with a negative step.
- For example, if s is a string, then s[::-1] will
return the reversed string.
3. Conversion of character to ASCII code
- To convert a character to its ASCII code in
Python, you can use the ord() function.
4. Conversion of ASCII code to character
- To convert an ASCII code to its
corresponding character, you can use the chr()
function.
5. To check number of vowels and consonants
- Define a set of vowels
- Define a function that takes a string as an
argument
- Loop through each character in the string
- Check if the character is a consonant
- Increment the consonant counter
- Return a tuple of vowel and consonant counts
6. To check if a string is palindrome
- Define a function that takes a string as an
argument.
- Reverse the string using slicing or a loop.
- Compare the original string and the reversed
string using the == operator.
- Return True if they are equal, False otherwise.

7. To check if a number is Armstrong


- Define a function that takes a number as a
parameter and returns the number of digits in it.
- Define another function that takes a number
as a parameter and returns the sum of its digits
raised to the power of the number of digits.
- In the main program, ask the user to enter a
number and store it in a variable.
- Call the second function with the user's
number as an argument and compare the result with
the original number.
- If they are equal, print that the number is
Armstrong, otherwise print that it is not.

8. To get prime factors of a number


- Initialize an empty list to store the factors
- Start with the smallest prime factor
- Loop until n is reduced to 1 or less
- If n is divisible by i, append i to the factors
list and divide n by i
- Otherwise, increment i by 1 and try again
- Return the factors list

9. To play a game
- Import the random module
- Generate a random number between 1 and 5
- Ask the user to enter their guess
- Check if the guess is equal to the number
- Print a success message
- Otherwise print a failure message and
the correct number.

10. To get factorial


- Define a function called factorial that takes a
parameter n.
- If n is zero or one, return one.
- Otherwise, return n multiplied by the
factorial of n minus one.
- Call the function with the desired number as
an argument and print the result.

11. Calculate volume and surface area of solids


- Use the math module to access some
constants and functions
- Define a function for each solid shape
- The function will take the parameters of the
shape and return a tuple of volume and surface area
x=input('''what do you want to do:
1) Calculator
2) String reversal
3) Conversion of character to ASCII code
4) Conversion of ASCII code to character
5) To check number of vowels and consonants
6) To check if a string is palindrome
7) To check if a number is armstrong
8) To get prime factors of a number
9) To play a game
10) To get factorial
11) Calculate volume and surface area of solids
''')
def calculator ():
x=input('''what do you want to do ?
add (+)
subtract (-)
multiply (*)
divide (/)
a raised to power b (power)
square root (sqrt)
cube root (cube root)
trigonometric function (trigo)
discount (disct)
table(table)
average(avg)
:''')
import math
you = math.pi
if x == '+' :
n=int(input("how many numbers you want to add:"))
d=0
for i in range(0,n):
b=int(input('enter no. :'))
d=d+b
print('sum is :',d)
elif x=='-':
b=int(input('enter first no. :'))
c=int(input('enter second no. :'))
d=b-c
print('difference is :',d)
elif x=='*':
n=int(input("how many numbers you want to multiply:"))
d=1
for i in range(0,n):
b=int(input('enter no. :'))
d=d*b
print('product is :',d)
elif x=='/':
b=int(input('enter first no. :'))
c=int(input('enter second no. :'))
d=b/c
print('division is :',d)
elif x=='power':
a=int(input('enter a:'))
b=int(input('enter b :'))
d=a**b
print(a,'raised to',b,' is :',d)
elif x=='sqrt':
a=int(input('enter number:'))
b=pow(a,0.5)
print('square root of',a,'is',b)
elif x=='cube root':
a=int(input('enter number:'))
b=pow(a,1/3)
print('cube root of',a,'is',b)
elif x=='trigo':
a=input('''which operation do you want to do
sin
cos
tan
cosec
sec
cot
:''')
b=float(input('enter angle in degree:'))
c=b*(you/180)
if a=='sin':
print('Sin of',b,'is:',math.sin(c))
elif a=='cos':
print('cos of',b,'is:',math.cos(c))
elif a=='tan':
print('tan of',b,'is:',math.tan(c))
elif a=='cosec':
d=1/math.sin(c)
print('cosec of',b,'is:',d)
elif a=='sec':
d=1/math.cos(c)
print('sec of',b,'is:',d)
elif a=='cot':
d=1/math.tan(c)
print('cot of',b,'is:',d)
else :
print(a,'is not a trigonometric function')
elif x=='disct':
a=int(input('enter amount:'))
if a>0:
b=int(input('enter disount in percentage:'))
c=(a*b)/100
d=a-c
print('discount:',c,'remaining amount:',d)
else:
print('enter valid discount amount')
elif x=="table":
u=int(input("upto how many digits you want table:"))
n=int(input("enter number:"))
for i in range(1,u+1):
print(n,"*",i,"=",n*i)
elif x=="avg":
n=int(input("how many number's average you want?"))
A=[]
for i in range (0,n):
z=int(input("enter number:"))
A.append(z)
B=0
for i in range(0,n):
S=A[i]
B=B+S
C=B/n
print("average is:",C)
import random
def rev(name):
l=len(name)
i=l-1
while(i>=0):
a=print(name[i],end="")
i=i-1
def string_reversal () :
n=input("enter text")
rev(n)
def ordi():
n=input("input character:")
l=len(n)
if l==1:
print("ascii code of",n,"is",ord(n))
else:
print("enter one character only")
def idi():
n=int(input("input ascii code:"))
if n>=0 & n<=255 :
print("ascii code=",n)
print("character=",chr(n))
else :
print("enter number in renge 0-255")
def vowels() :
n=input("enter word containing alphabets only:")
l=n.lower()
b=n.isalpha()
if b==True:
v=0
c=0
for ch in l:
if ch=="a" or ch=="e" or ch=="i" or ch=="o" or
ch=="u" :
v=v+1
else:
c=c+1
print("no. of vowels=",v)
print("no. of consonants=",c)
else:
print("enter single word containing alphabets only")
def palindrome():
n=input("enter text").lower()
if n==n[::-1]:
print(n,"is palindrome")
else:
print(n,"is not palindrome")
def armstrong():
d=0
n=int(input("enter number:"))
k=n
while n>0:
s=str(n)
l=len(s)
r=n%10
c=r**l
d=d+c
n=n//10
z=d
if z==k:
print(k,"is armstrong")
else :
print(k,"is not armstrong")
def prime_factors():
A=[]
B=[]
z=int(input("enter number"))
for k in range(2,z):
if z%k==0:
n=k
a=0
for i in range (2,n):
if n%i==0:
a=a+1
if a==0:
A.append(k)
print(A)
def game():
a=random.randint(1,6)
for i in range(1,5):
n=int(input("guess no. between 1 and 5:"))
if a==n:
print("you won")
break
else:
c=4-i
if c>0:
print("try again",c,"chances left")
else:
print("you lost")
def factorial():
a=1
n=int(input("enter number:"))
if n==0:
print("factorial of 0 is 1")
elif n>0:
for i in range(1,n+1):
a=a*i
print("factorial of",n,"is",a)
def shapes():
e=1
while e!=0:
print("To calculate volumes and surface areas of following
shapes ")
print("1. Cube")
print("2. Cuboid")
print("3. Cylinder")
print("4. Cone")
print("5. Sphere")
print("6. Hemisphere")
print("0. Exit")
c = int(input("Type the serial number of the shape = "))
if c>0 and c<7:
if c == 1 :
shape = "Cube"
a=int(input("Enter the value of side of the Cube : "))
vol=a**3
sa=6*a**2
elif c == 2:
shape="Cuboid"
l=int(input("Enter the value of length of the Cuboid :
"))
w=int(input("Enter the value of width of the Cuboid :
"))
h=int(input("Enter the value of height of the Cuboid :
"))
vol=l*w*h
sa=l*w+l*h+w*h
sa=2*sa
elif c == 3:
shape = "Cylinder"
r = int(input("Enter the value of radius of the
Cylinder : "))
h = int(input("Enter the value of height of the
Cylinder : "))
vol=22/7*r**2*h
sa=r+h
sa=2*22/7*r*sa
elif c == 4:
shape = "Cone"
r = int(input("Enter the value of radius of the Cone :
"))
h = int(input("Enter the value of height of the Cone :
"))
vol=1/3*22/7*r**2*h
s1=(r**2+h**2)**0.5
sa=r+s1
sa=22/7*r*sa
elif c == 5:
shape="Sphere"
r=int(input("Enter the value of radius of the Sphere:
"))
vol=4/3*22/7*r**3
sa=4*22/7*r**2
elif c == 6:
shape="Hemisphere"
r=int(input("Enter the value of radius of the
Hemisphere : "))
vol=2/3*22/7*r**3
sa=3*22/7*r**2
print ("Choosen shape is ",shape)
print ("Volume of ",shape,"is =",vol)
print ("Surface Area of ",shape,"is =",sa)
print ("")
str =input("Press ENTER Key to continue")
elif c>6:
print("")
print("Please enter a valid serial number of the shape")
print("")
e=c
if e==0:
break
if x == '1':
calculator()
elif x == '2':
string_reversal()
elif x == '3':
ordi()
elif x == '4':
idi()
elif x == '5':
vowels()
elif x == '6':
palindrome()
elif x == '7':
armstrong()
elif x == '8':
prime_factors()
elif x == '9':
game()
elif x == '10':
factorial()
elif x == '11':
shapes()
 When choice is 1

 When choice is +
 When choice is -

 When choice is *

 When choice is /

 When choice is power

 When choice is sqrt


CHOICE 1

CHOICE 2

 When choice is cube root


CHOICE 1

CHOICE 2
 When choice is trigo

 When choice is sin

 When choice is cos

 When choice is tan

 When choice is cosec

 When choice is sec

 When choice is cot


 When choice is disct

 When choice is table

 When choice is avg

 When choice is 2.

 When choice is 3.

 When choice is 4.

 When choice is 5.
CHOICE 1
CHOICE 2

 When choice is 6.
CHOICE 1

CHOICE 2

 When choice is 7.
CHOICE 1

CHOICE 2

 When choice is 8.
 When choice is 9.
CHOICE 1

CHOICE 2

 When choice is 10.

 When choice is 11.


 When choice is 1.

 When choice is 2.

 When choice is 3.

 When choice is 4.

 When choice is 5.
 When choice is 6.

 When choice is 0.
 Introduction to Python (w3schools.com)

You might also like