pravin python micro project
pravin python micro project
AbstrAct
The simple calculator is a system software which allows us to perform simple
mathematical operations such as addition, substraction , multiplication, division
etc. To develop this system we have used the concept of class and object first
we defined the class calculator and defined the various function inside this class
for various mathematical operations and each function is different from each
other. After that we prompted user to provide the input for two numbers. And
at the end of the program we have created the object of calculator class and
called all the function defined inside the class one after one for different tasks as
per their respective operations.
INtroDuctIoN
Python is a widely used general-purpose, high level programming language. It
was created by Guido van Rossum in 1991 and further developed by the Python
Software Foundation. It was designed with an emphasis on code readability, and
its syntax allows programmers to express their concepts in fewer lines of code.
Python is a programming language that lets you work quickly and integrate
systems more efficiently. Python is a powerful general-purpose programming
language. It is used to develop web applications, data science, creating software
prototypes and so on. Fortunately for beginners, Python has simple easy-to-use
syntax. This makes Python an excellent language to learn to program for
beginners. A class is a code template for creating objects. Objects have member
variables and have behaviour associated with them. In python a class is created
by the keyword class.An object is created using the constructor of the class. This
object will then be called the instance of the class. In Python we create
instances in the following manner
Instance = class(arguments)
A class by itself is of no use unless there is some functionality associated with it.
Functionalities are defined by setting attributes, which act as containers for data
and functions related to those attributes. Those functions are called methods.
Attributes:
A class by itself is of no use unless there is some functionality associated with it.
Functionalities are defined by setting attributes, which act as containers for data
and functions related to those attributes. Those functions are called methods.
You can define the following class with the name Snake. This class will have an
attribute name.
>>> class Snake:
... name = "python" # set an attribute `name` of the class
…
A function object is created with the def statement. Primarily, we want to
evaluate the function objects we create. However, because a function is an
object, it has attributes, and it can be manipulated to a limited extent.
From a syntax point of view, a name followed by ()'s is a function call. You can
think of the ()'s as the "call" operator: they require evaluation of the arguments,
then they apply the function.
name ( arguments )
When we use a function name without ()'s, we are talking about the function
object. There are a number of manipulations that you might want to do with a
function object.
Call The Function. By far, the most common use for a function object is to call
it. When we follow a function name with ()'s, we are calling the function:
evaluating the arguments, and applying the function. Calling the function is the
most common manipulation.
Alias The Function. This is dangerous, because it can make a program
obscure. However, it can also simplify the evoluation and enhancement of
software. Imagine that the first version of our program had two functions
named rollDie and rollDice.
By using the above concept we have developed the simple calculator system we
have developed this system we have used the concept of class and object first
we defined the class calculator and defined the various function inside this class
for various mathematical operations and each function is different from each
other. After that we prompted user to provide the input for two numbers. And
at the end of the program we have created the object of calculator class and
called all the function defined inside the class one after one for different as per
their respective operations.
LItErAturE survEy
One of my first tasks as a new post-doc was to undertake a systematic
quantitative literature review. We wanted to get a feel for the international & NZ
literature on functional biodiversity in agroecosystems, and this was a bit
daunting for me as I my background is in invasions, not native biodiversity or
agriculture! Luckily, the review method we chose relies on data, not expert
knowledge - we chose the method developed by Griffith University
(https://www.griffith.edu.au/griffith-sciences/school-
environmentscience/research/systematicquantitative-literature-review). It's
quite an exhaustive process but the method does a really good job of catching
easily overlooked papers, and provides a reproducible and transparent method
for conducting reviews and meta-analyses. I'm a fan!
The first few steps involve defining your keywords and databases for
undertaking the searches, and designing a way of storing your papers and
extracting the data. Once you've completed the first 10% of your search,
though, you'll need to do a stock-take of the papers that you're picking up and
make sure you haven't missed any key words in your search terms.
It was at this point that I realized two things: a) automating this would save me a
lot of time, and b) there were no existing programs that could do what I wanted.
So, I wrote up some python code to read in all papers, extract the keywords and
write them to a new text file. I then used R to rank them by how commonly they
occurred and graph the results, and added any commonlyoccurring keywords to
my database search strings.
Er DIAgrAm
ImpLEmENtAtIoN
class Calculator:
def addition(self):
print(a + b)
def subtraction(self):
print(a - b)
def multiplication(self):
print(a * b)
def division(self):
print(a / b)
a = int(input("Enter first number:"))
b = int(input("Enter first number:"))
obj = Calculator()
choice = 1 while
choice != 0:
print("1. ADDITION") print("2”)
SUBTRACTION") print("3”)
MULTIPLICATION") print("4”)
DIVISION") choice = int(input("Enter
your choice:")) if choice == 1:
print(obj.addition())
elif choice == 2:
print(obj.subtraction())
elif choice == 3: print(obj.multiplication())
elif choice == 4:
print(obj.division())
else:
output
Enter first number:3
Enter first number:2
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
Enter your choice:1
5
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
Enter your choice:2
1
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
Enter your choice:3
6
1. ADDITION
2. SUBTRACTION
3. MULTIPLICATION
4. DIVISION
Enter your choice:4
coNcLusIoN
We have concluded that we have successfully developed a simple calculator
system which perform the various mathematical operations. We have used the
concept of class and object to implement this system and perform a lot of
customization so that teachers don’t need to change anything. We have provide
the four functions and each function is responsible for their respective tasks.
This project helps to all the user to perform the mathematical operations very
easily.
rEfErENcEs
Books:
1. Python Crash Course
2. Head First Python
3. Learn Python the Hard Way
4. A Byte of Python
Websites:
https://www.w3schools.com/python/
https://www.codingninjas.com/
https://www.tutorialspoint.com/python/.py
https://www.zapmeta.co.in/
print(“ Invalid choice”)