Type Here to Get Search Results !

ads

Python Programmming- Introduction, Variables, and Data Types

PYTHON PROGRAMMING


Introduction:

History Python is a widely used programming language today.  Python was developed by Guido van Rossam, a Dutch programmer, and released in 1991.

Guido van Rossam


 The name is inspired from a BBC comedy show Monty Python’s Flying Circus. Python is a successor of the ABC programming language. At the time of this writing, Python 3 is the latest major release of Python (on your computers, you may notice the program python3). Since the last 20 years, Python has been in the Top 10 most popular programming languages. At the time of this writing (July 2022), Python is the most popular language, surpassing C and Java (according to the TIOBE index).

Python Programming Logo

“Two snakes” logo of Python


Features: Python is a general-purpose programming language and supports multiple paradigms or ways of programming For instance, we can write procedural (sequence of steps) as well as object-oriented programs (entities as objects and communication using messages across them) in it. It can also be used to write functional programs (applying and composing functions), among others. Unlike C and C++, Python is interpreted. This means Python programs are not compiled and stored into a binary code file 3 (e.g., an executable)., but its source is translated into machine code and executed by the interpreter directly (without us seeing the executable code). Thus, on your computers, python3 is an interpreter (and gcc is a compiler for C programs). Python is also dynamically-typed. This means that the type of a variable may not be specified in the source code, and is identified when the program executes. Python also relies on garbage collection which reclaims the allocated memory of the variables which are no longer needed (referenced, to be precise). This relieves the programmer of the task of memory deallocation, similar to Java. Python also has a large variety of standard libraries, which allow us to write complex codes quickly, improving our productivity.


Why Python programming is needed:

Python is a popular high-level programming language used for a wide range of applications. Here are some of the reasons why Python programming is needed:

Easy to learn: Python has a simple syntax and a straightforward structure, making it easy for beginners to learn.

Versatility: Python is a versatile language that can be used for web development, machine learning, data analysis, game development, and more.

Large community: Python has a large and supportive community, which means that there are many resources available for learning and problem-solving.

Libraries and frameworks: Python has a wide range of libraries and frameworks that can be used for various tasks, such as data analysis, web development, and machine learning.

Productivity: Python has a concise syntax and a large number of libraries, which can help developers write code faster and with fewer errors.

Career opportunities: Python is one of the most in-demand programming languages in the job market, with high-paying job opportunities in various industries.

Overall, Python is a powerful language that can help developers build a variety of applications quickly and efficiently.

Installation and Execution:

you can download the appropriate installable for Windows or Linux or iPadOS or other operating systems from Python’s official website www.python.org.

Python IDES's

1)Pycharm---------->mostly used

2)Pydev

3)Komodo

4)Spyder

5)Eclipse

6)NEtbeans

7)Jupyter Notebook

8)VSCode

9)Atom

-----------------------------------------------------------------------------------------------

Python Execution Modes:  Two modes of Execution

1)Interactive mode

2)Batch mode

Interactive mode: Here we directly type our python stmts on interpreter and can  easily communicate line by line.

Advantage: For learning Python and to test the functionalities of python

Batch mode: Here we write set or batch of stmts within Editors/IDE's and save it by using .py extension and later submit to python interpreter.

various Editors

1)Notepad

2)Editplus

3)vi 

4)nano

5)gedit

Various IDE's (Integrated Development Environment)

1)Pycharm---------->mostly used

2)Pydev

3)Komodo

4)Spyder

5)Eclipse

6)Netbeans

7)Jupyter Notebook

8)VSCode

9)Atom

-----------------------------------------------------------------------------------------------

Developing Python Applications using Editors

ex:Notepad

open notepad and type the following python stmts.

x=10

y=20

print(x+y)

print(x-y)

print(x*y)

print(x/y)

save it using sample.py extension and later submit to python interpreter.

submitting the file to interpreter------->

goto cmdprompt---->python C:\pythonweekend\sample.py

It gives the ouput

Data types: There are two types of  data types. Fundamental Data types and Collection Datatypes 

1.Fundamental Datatypes:  it is object holding a single value. there are five types.

  1.int ----->age=25

  2.float --->sal=90870.40

  3.boolean-->True/False

  4.string -->city="Hyderabad"

  5.complex-->x+jy


2.Collection Datatypes: it is object holding group of values. there are four types.

1.List  ------->[ ]  ex: x=[10,20,30,40]

2.Tuple ------->( )      y=(10,20,30,40)

3.Set   ------->{ }      z={10,20,30,40}

4.Dictionary -->{k:v}    p={"Name":"Ajay" ,"Age":25}

                                               k       v

Python Variables: Python does not have to declare any type of the variable. this is handled internally according to the type of value assigned to the variable.

>>>Name= "Simran"                       // Name act as a string type
>>>Age= 30                                    //Age act as a integer type

input() function in Python: The input() function in Python is used to take any form of inputs from the user/standard input device, which can later be processed accordingly in the program. It is complementary to the print() function.
 >>> print('Enter your name.')
 >>> myName = input() 
>>> print('Hello, {}'.format(myName)) Enter your name. 
Simran Hello, Simran

Post a Comment

2 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.