Python is a simple, high level, interpreted, interactive, object oriented programming language when compared to other programming languages. It is very robust, elegant and powerful language.Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional programming
What Is a Program?
Table of Contents
An instruction set that describes how to carry out a computation is known as a programme.
The calculation could be mathematical, such as the solution of a system of
Equations or determining a polynomial’s roots are two examples, although a symbolic computation can also be used.
such as text replacement in a document or a graphical representation, like
playing a movie or processing an image.
The specifics vary depending on the language, however a few fundamental guidelines are present in
essentially all languages
input:
Obtain information from a keyboard, file, network, or other device.
output:
Data can be displayed on the screen, saved in a file, sent over the network, and other things.
math:
Addition and multiplication are examples of simple mathematical operations.
execution under condition
Run the relevant code after making sure certain conditions are met.
repetition:
repeat a specific action, usually with some modification.
That’s really all there is to it, believe it or not. all the software you’ve ever used,
no matter how complex, is composed of steps that essentially look like
these. Thus, you might see programming as the act of deconstructing a huge, complex system.
activity into increasingly smaller subtasks until they are easy enough to be completed
Running Python
One of the challenges of getting started with Python is that you might have to install
Python and related software on your computer. If you are familiar with your operat‐
ing system, and especially if you are comfortable with the command-line interface,
you will have no trouble installing Python. But for beginners, it can be hard to
learn about system administration and programming at the same time.
To avoid that problem, We recommend that you start out running Python in a browser.
There are a number of web pages you can use to run Python. If you already have a
favorite, go ahead and use it.
There are two versions of Python, called Python 2 and Python 3. They are very simi‐
lar, so if you learn one, it is easy to switch to the other. In fact, there are only a few
differences you will encounter as a beginner.
The Python interpreter is a program that reads and executes Python code. Depend‐
ing on your environment, you might start the interpreter by clicking on an icon, or by
typing python on a command line.
The first program
The first programme you create in a new language is typically titled “Hello, World! ”
due to the fact that all it does is show “Hello, World!”
This is how it appears in Python:
>>>print( “Hello, World!”)
Although it doesn’t actually print anything, this is an example of a print statement.
A result is shown on the screen. The outcome in this instance are the words.
Hello, World!
The quotation marks in the program mark the beginning and end of the text to be
presented; they do not show up in the final result
Print is a function, as shown by the parenthesis.
In Python, the print statement is slightly different; it is not a function, so it doesn’t
parentheses are used
>>>print ‘Hello, World!’
That’s enough to get started, but this distinction will soon make more sense.
Arithmetic Operators
Arithmetic Operators
After “Hello, World”, the next step is arithmetic. Python provides operators, which
are special symbols that represent computations like addition and multiplication.
The operators +, -, and * perform addition, subtraction, and multiplication, as in the
following examples:
- +(Addition)
This operators is used to add the values present on the sides of the operator.
Example
10+2=12
or
x+y=12 # x=10, y=2
- -(subtraction)
This operator is used to subtract one operator from another operand
Example
10-2=8
or
x-y=8 # x=10, y=2
- *(Multiplication)
This operator is used to multiply the value present on both sides of the operator
Example
10*2=20
or
x
x*y=20 # x=10, y=2
- /(Division)
This operator is used to divide one operand for another operand
10/2=5
or
x/y=5 # x=10, y=2
- %(Modulus)
This operator is used to divide two operand and it returns the remainder
Example
10%2=0
or
x%y=0 # x=10, y=2
- **(Exponent)
This operator is used to determine the of a numeric value
Example
10**2=100 #10 power 2
or
x**y=100 #x=10, y=2
- //(floor Division)
this operator is used to divide two operands and return the quotient after eliminating the decimal point. Here, if any one operand is negative, then result is floored that is rounded to the smallest whole number which is on its immediate left on the number line.
Example
25//2=12
25.0//2.0=12.0
-25//3=-8
-25//3=-8.0