Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Python Programming

Rating
-
Sold
-
Pages
38
Uploaded on
04-10-2025
Written in
2022/2023

The document is all about python Programming for beginners, wherever its different from other programming languages & consists of several methods , loops, Data types, which should be used . By throughout u will gain basic knowledge on this particular topic...

Show more Read less
Institution
Course

Content preview

PYTHON
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is
designed to be highly readable. It uses English keywords frequently where as other languages
use punctuation, and it has fewer syntactical constructions than other languages.
● Python is Interpreted − Python is processed at runtime by the interpreter. You do not
need to compile your program before executing it. This is similar to PERL and PHP.
● Python is Interactive − You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
● Python is Object-Oriented − Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
● Python is a Beginner's Language − Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from simple
text processing to WWW browsers to games.
History of Python
Python was developed by Guido van Rossum in the late eighties and early nineties at the
National Research Institute for Mathematics and Computer Science in the Netherlands.
Python is derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
SmallTalk, and Unix shell and other scripting languages.
Python is copyrighted. Like Perl, Python source code is now available under the GNU General
Public License (GPL).
Python is now maintained by a core development team at the institute, although Guido van
Rossum still holds a vital role in directing its progress.
Python Features
Python's features include −
● Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.
● Easy-to-read − Python code is more clearly defined and visible to the eyes.

● Easy-to-maintain − Python's source code is fairly easy-to-maintain.
● A broad standard library − Python's bulk of the library is very portable and cross-
platform compatible on UNIX, Windows, and Macintosh.
● Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.
● Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
● Extendable − You can add low-level modules to the Python interpreter. These modules
enable programmers to add to or customize their tools to be more efficient.
● Databases − Python provides interfaces to all major commercial databases.
● GUI Programming − Python supports GUI applications that can be created and ported
to many system calls, libraries and windows systems, such as Windows MFC,
Macintosh, and the X Window system of Unix.

, ● Scalable − Python provides a better structure and support for large programs than shell
scripting.



Apart from the above-mentioned features, Python has a big list of good features, few are listed
below −
● It supports functional and structured programming methods as well as OOP.

● It can be used as a scripting language or can be compiled to byte-code for building large
applications.
● It provides very high-level dynamic data types and supports dynamic type checking.

● It supports automatic garbage collection.
● It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

Basic Syntax of Python
Indentation and Comment in Python
Indentation is the most significant concept of the Python programming language. Improper use of
indentation will end up "IndentationError" in our code.
Indentation is nothing but adding whitespaces before the statement when it is needed. Without indentation
Python doesn't know which statement to be executed to next. Indentation also defines which statements
belong to which block. If there is no indentation or improper indentation, it will display
"IndentationError" and interrupt our code.




Python indentation defines the particular group of statements belongs to the particular block. The
programming languages such as C, C++, java use the curly braces {} to define code blocks.
In Python, statements that are the same level to the right belong to the same block. We can use four
whitespaces to define indentation. Let's see the following lines of code.
Example -
1. list1 = [1, 2, 3, 4, 5]
2. for i in list1:
3. print(i)
4. if i==4:
5. break

,6. print("End of for loop")
Explanation:
In the above code, for loop has a code blocks and if the statement has its code block inside for loop. Both
indented with four whitespaces. The last print() statement is not indented; that's means it doesn't belong to
for loop.

Python Data Types
Variables can hold values, and every value has a data-type. Python is a dynamically typed
language; hence we do not need to define the type of the variable while declaring it. The
interpreter implicitly binds the value with its type.
a=5
The variable a holds integer value five and we did not define its type. Python interpreter will
automatically interpret variables a as an integer type.
Python enables us to check the type of the variable used in the program. Python provides us
the type() function, which returns the type of the variable passed.
Consider the following example to define the values of different data types and checking its type.
a=10
b="Hi Python"
c = 10.5
print(type(a))
print(type(b))
print(type(c))
Python provides various standard data types that define the storage method on each of them. The
data types defined in Python are given below.
1. Numbers
2. Sequence Type
3. Boolean
4. Set
5. Dictionary




Numbers
Number stores numeric values. The integer, float, and complex values belong to a Python
Numbers data-type. Python provides the type() function to know the data-type of the variable.
Similarly, the isinstance() function is used to check an object belongs to a particular class.
Python creates Number objects when a number is assigned to a variable. For example;
a=5

, print("The type of a", type(a))

b = 40.5
print("The type of b", type(b))

c = 1+3j
print("The type of c", type(c))
print(" c is a complex number", isinstance(1+3j,complex))
Python supports three types of numeric data.
1. Int - Integer value can be any length such as integers 10, 2, 29, -20, -150 etc. Python has
no restriction on the length of an integer. Its value belongs to int
2. Float - Float is used to store floating-point numbers like 1.9, 9.902, 15.2, etc. It is
accurate upto 15 decimal points.
3. complex - A complex number contains an ordered pair, i.e., x + iy where x and y denote
the real and imaginary parts, respectively. The complex numbers like 2.14j, 2.0 + 2.3j,
etc.
Sequence Type
String
The string can be defined as the sequence of characters represented in the quotation marks. In
Python, we can use single, double, or triple quotes to define a string.
String handling in Python is a straightforward task since Python provides built-in functions and
operators to perform operations in the string.
In the case of string handling, the operator + is used to concatenate two strings as the
operation "hello"+" python" returns "hello python".
The operator * is known as a repetition operator as the operation "Python" *2 returns 'Python
Python'.
The following example illustrates the string in Python.
Example - 1
str = "string using double quotes"
print(str)
s = '''''A multiline
string'''
print(s)
Consider the following example of string handling.
Example - 2
str1 = 'hello javatpoint' #string str1


str2 = ' how are you' #string str2
print (str1[0:2]) #printing first two character using slice operator
print (str1[4]) #printing 4th character of the string
print (str1*2) #printing the string twice
print (str1 + str2) #printing the concatenation of str1 and str2
List
Python Lists are similar to arrays in C. However, the list can contain data of different types. The
items stored in the list are separated with a comma (,) and enclosed within square brackets [].

Written for

Institution
Course

Document information

Uploaded on
October 4, 2025
Number of pages
38
Written in
2022/2023
Type
Class notes
Professor(s)
Ms.k.sumalatha
Contains
All classes

Subjects

$18.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
NikhithaDasari

Get to know the seller

Seller avatar
NikhithaDasari Chaitanya deemed to be university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions