Python is high-level, interpreted and general-purpose programming language. Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
Web Development(server-side).
Software development.
Mathematics
System scripting.
What Python can do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready software development.
Why Python?
Python can be treated in a procedural way, an object-orientated way or a functional way.
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
Python has a simple syntax similar to the English language.
Python has a syntax that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Modern Computer Systems:
A computer is a machine that can be instructed to carry out sequences of arithmetic and logical operations automatically via computer programming. Modern computers have the ability to follow generalized sets of operations, called programs. These programs enable computers to perform an extremely wide range of tasks. A "complete" computer including the hardware, the operating system(main software), and peripheral equipment required and used for "full" operation can be referred to as a computer system. This term may as well be used for a group of computers that are connected and work together, in particular, a computer network or computer cluster.
Features of Python:
Python is still somewhat relatively new to the general software development industry. When people ask, "What is python ?" it is difficult to say one thing. The tendency is to want to blurt out all the things that you feel Python is in one breath.
Here are some major features of python:
High Level.
Object-Oriented.
Scalable.
Extensible.
Portable.
Easy to learn.
Easy to read.
Easy-to-maintain.
Interpreter based language.
Python source files typically end with .py extension.
Installing Python:
Platforms with ready to install binaries require only the file download and initiation of the installation of an application.
In, general these are the steps to install python in the system:
(a). go to python.org.
(b). Click on the downloads section.
(c). Run the link according to the operating system installed in your system.
(d).When the download is the complete go-ahead to your downloads folder and run .exe file.
(e). Follow the steps. Python is installed.
Running Python:
Python comes with an interactive interpreter. When you type python in your shell or command prompt, the python interpreter becomes active with >>> prompt and waits for your command.
Now, you can type any valid expression at the prompt. Python reads the typed expression, evaluates it and print the results.
Running Python scripts in IDLE:
Goto FILE menu click on the NEW file and write the code and save num.py. and run the program by F5 or run module.
Output:
Python Keywords:
The following words are the keywords, which form the basis of the Python language. You are not allowed to use these words to name your variables, because these are the core commands of Python. They must be spelt exactly as written here for the interpreter to recognize them as keywords. The words True, False and None have a special meaning, which will be covered later.
For example:
Elif, else, except, finally, for, from, global, if, import and many more.
Python Data Types:
Data types are the classification or categorization of data items. Data types represent a kind of value which determines what operations can be performed on that data. Numeric, non-numeric and Boolean (true/false) data are the most used data types. However, each programming language has its own classification largely reflecting its programming philosophy.
Python has the following data types:
Numeric:
Int: Stores integer value.
For eg: a=5
For eg: a=5
Float: Stores decimal value.
For eg: a=5.0
For eg: a=5.0
Boolean:
True: yields true if the condition given is true.
false: yields false if the given condition is false.
Sequence:
List:
A list object is an ordered collection of one or more data items, not necessarily of the same type, put in square brackets.
A Tuple object is an ordered collection of one or more data items, not necessarily of the same type, put in parentheses.
String:
A string value is a collection of one or more characters put in single, double or triple quotes.
Dictionary:
A dictionary object is an unordered collection of data in a key: value pair form. A collection of such pairs is enclosed in curly brackets.
For example:
Those quantities where values can be changed or modify during the execution of the program.
<variable-name> = <expression>
eg: name="ABC'
<variable-name> = <expression>
eg: name="ABC'
(a) Single value to a single variable:
a=5
name='abc'
(b) Single value to multiple variables:
(c) Multiple values to multiple variables:
Conversion data types:
We can convert from one to another type with function int() for integer float() for float and complex() for complex.
(a) Convert into float:
a=5print(float(a)) #Convert integer type into float type
Output:
a=5.0print(int(a)) #convert float type into int.
Output:
0 Comments
Doubts? Please let our team know So that we can serve you better.