100% found this document useful (1 vote)
207 views

Python

This document provides an overview of Python programming. It discusses what Python is, what it can be used for, its features, syntax, operators, data types, file handling and more. The key points are that Python is an easy to learn programming language used for web development, software development and data science. It works across platforms and has simple syntax that resembles English.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
207 views

Python

This document provides an overview of Python programming. It discusses what Python is, what it can be used for, its features, syntax, operators, data types, file handling and more. The key points are that Python is an easy to learn programming language used for web development, software development and data science. It works across platforms and has simple syntax that resembles English.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Summer Training on Python Programming

Name :-Saurav Kumar Sultania


Reg. No:- 11800321
What is Python ?

 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 can Python 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 works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
 Python has a simple syntax similar to the English language.
 Python has 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.
 Python can be treated in a procedural way, an object-orientated way or a functional way.
Python Syntax compared to other programming
languages

 Python was designed for readability, and has some similarities to the English language with
influence from mathematics.
 Python uses new lines to complete a command, as opposed to other programming
languages which often use semicolons or parentheses.
 Python relies on indentation, using whitespace, to define scope; such as the scope of loops,
functions and classes. Other programming languages often use curly-brackets for this
purpose.
PYTHON FEATURES
 Python provides lots of features that are listed below.
 1) Easy to Learn and Use
Python is easy to learn and use. It is developer-friendly and high-level programming language.
 2) Expressive Language
Python language is more expressive means that it is more understandable and readable.
 3) Interpreted Language
Python is an interpreted language i.e. interpreter executes the code line by line at a time. This makes
debugging easy and thus suitable for beginners.
 4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, Unix and Macintosh etc. So, we
can say that Python is a portable language.
 5) Free and Open Source
Python language is freely available at official web address. The source-code is also available. Therefore, it
is open source.
 6) Object-Oriented Language
Python supports object-oriented language and concepts of classes and objects come into existence.
Python Casting

 int() - constructs an integer number from an integer literal, a float literal (by rounding down
to the previous whole number), or a string literal (providing the string represents a whole
number)
 float() - constructs a float number from an integer literal, a float literal or a string literal
(providing the string represents a float or an integer)
 str() - constructs a string from a wide variety of data types, including strings, integer literals
and float literals
Example
x = int(1) # x will be 1
y = int(2.8) # y will be 2
Python Operators

 Operators are used to perform operations on variables and values.


 Python divides the operators in the following groups:
 Arithmetic operators
 Assignment operators
 Comparison operators
 Logical operators
 Identity operators
 Membership operators
 Bitwise operators
Python Collections

There are four collection data types in the Python programming language:
 List is a collection which is ordered and changeable. Allows duplicate members. In Python
lists are written with square brackets.
 Example
Create a List:
thislist= ["apple", "banana", "cherry"]
print(thislist)
 Tuple is a collection which is ordered and unchangeable.
Allows duplicate members. In Python tuples are written with
round brackets.
Example
Create a Tuple:
thistuple = ("apple", "banana", "cherry")
print(thistuple)

 Set is a collection which is unordered and unindexed. No


duplicate members. In Python sets are written with curly
brackets.
Example
Create a Set:
thisset = {"apple", "banana", "cherry"}
print(thisset)
 Dictionary is a collection which is unordered, changeable and
indexed. No duplicate members. In Python dictionaries are
written with curly brackets, and they have keys and values.
Example
Create and print a dictionary:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
File Handling

The key function for working with files in Python is the open () function.
The open () function takes two parameters; filename, and mode.
There are four different methods (modes) for opening a file:
"r" - Read - Default value. Opens a file for reading, error if the file does not exist
"a" - Append - Opens a file for appending, creates the file if it does not exist
"w" - Write - Opens a file for writing, creates the file if it does not exist
"x" - Create - Creates the specified file, returns an error if the file exists
Syntax

To open a file for reading it is enough to specify the name of the file:

f = open("demofile.txt")
Write to an Existing File
To write to an existing file, you must add a parameter to the open() function:
"a" - Append - will append to the end of the file
"w" - Write - will overwrite any existing content
Example
Open the file "demofile2.txt" and append content to the file:
f = open ("demofile2.txt", "a")
f. write("Now the file has more content!")
f.close()
f = open("demofile2.txt", "r")
print(f.read())
LEARNING OUTCOMES

 1. To acquire programming skills in core Python.


 2. To acquire Object Oriented Skills in Python
 3. To develop the skill of designing Graphical user Interfaces in Python
 4. To develop the ability to write database applications in Python

You might also like