You are on page 1of 28

INTERNSHIP REPORT ON

PYTHON PROGRAMMING
A
TRAINING REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE
REQUIREMENTS FOR THE AWARD OF DEGREE OF
BACHELOR OF TECHNOLOGY
IN
ELECTRICAL AND ELECTRONICS ENGINEERING
BY
GANTAKOLLA BHUVAN SHASHANK (21A91A0215)

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

ADITYA ENGINEERING COLLEGE (A)

Approved by AICTE, Permanently Affiliated to JNTUK & Accredited by NAAC with ‘A++’ Grade,
Accredited by NBA, Recognized by UGC under the sections 2(f) and 12(B) of the UGC act 1956
Aditya Nagar, ADB Road – Surampalem – 533437, Kakinada Dist., A.P.,
2023-2024
Python Programming

INTERNSHIP LETTER

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 2


Python Programming

Student’s Declaration

I GANTAKOLLA BHUVAN SHASHANK, a student of B. Tech (EEE) Program, with


Roll No.21A91A0215 of the Department of Electrical and Electronics Engineering, Aditya
Engineering College, do hereby declare that I have completed the mandatory summer
internship from 26-06-2023 to 22-07-2023 on Python Programming from Technical Hub
under the Faculty Guideship of Ch.B. Ayyappa Raju, Department of Electrical and
Electronics Engineering, ADITYA ENGINEERING COLLEGE.

By

GANTAKOLLA BHUVAN SHASHANK

(21A91A0215)

Faculty Guide Head of the Department

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 3


Python Programming

ACKNOWLEDGMENT

Training has an important role in exposing the real-life situation in an industry. It was a
great experience for me to work on training at TECHNICAL HUB through which I could learn
how to work in a professional environment. Now, I would like to thank the people who guided
me and have been a constant source of inspiration throughout the tenure of my internship
training.

I am sincerely grateful to NANI (Python Trainer) at TECHNICAL HUB who rendered me


his valuable assistance, constant encouragement and able guidance which made this training
actually possible. I feel elated to thank BABJI NEELAM C.E.O of TECHNICAL HUB for his
support and immense cooperation in completion of my project work.

I wish my deep sense of gratitude to Dr V. Srinivasa Rao, HOD, Department of Electrical


and Electronics whose guidance and encouragement made my training successful.

GANTAKOLLA BHUVAN SHASHANK


(21A91A0215)

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 4


Python Programming

CONTENTS

S.NO. NAME OF THE CONTENT PAGE NO.

1 ACKNOWLEDGMENT 4

2 INTRODUCTION TO PYTHON 6

3 PYTHON OPERATORS 8

4 DATA STRUCTURES IN PYTHON 10

5 PYTHON LISTS 10

6 PYTHON DICTIONARY 13

7 PYTHON TUPLES 16

8 PYTHON SETS 18

9 PYTHON STRINGS 21

10 PYTHON LOOPS 24

11 INTRIDUCTION TO TECHNICAL HUB 27

12 CONCLUSION 28

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 5


Python Programming

INTRODUCTION TO PYTHON

History of Python
Python is a widely-used general-purpose, high-level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was
mainly developed for emphasis on code readability, and its syntax allows programmers to express
concepts in fewer lines of code.

In the late 1980s, history was about to be written. It was that time when working on Python
started. Soon after that, Guido Van Rossum began doing its application-based work in December of
1989 at Centrum Wickenden & Informatica (CWI) which is situated in the Netherlands. It was
started firstly as a hobby project because he was looking for an interesting project to keep him
occupied during Christmas.

What is python?

Python is a high-level scripting language which can be used for a wide variety of text processing,
system administration and internet-related tasks. Unlike many similar languages, its core language is
very small and easy to master, while allowing the addition of modules to perform a virtually limitless
variety of tasks. Python is a true object-oriented language, and is available on a wide variety of
platforms. There’s even a python interpreter written entirely in Java, further enhancing python’s
position as an excellent solution for internet-based problems.

Python was developed in the early 1990’s by Guido van Rossum, then at CWI in Amsterdam, and
currently at CNRI in Virginia. In some ways, python grew out of a project to design a computer
language which would be easy for beginners to learn, yet would be powerful enough for even
advanced users. This heritage is reflected in python’s small, clean syntax and the thoroughness of the
implementation of ideas like object-oriented programming, without eliminating the ability to program
in a more traditional style. So, python is an excellent choice as a first programming language without
sacrificing the power and advanced capabilities that users will eventually need.

Although pictures of snakes often appear on python books and websites, the name is derived
from Guido van Rossum’s favourite TV show, “Monty Python’s Flying Circus”. For this reason, lots
of online and print documentation for the language has a light and humorous touch. Interestingly,
many experienced programmers report that python has brought back a lot of the fun they used to have
programming, so van Rossum’s inspiration may be well expressed in the language itself.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 6


Python Programming

Why Python?
The language’s core philosophy is summarized in the document The Zen of Python (PEP 20), which
includes aphorisms such as…

 Beautiful is better than ugly


 Simple is better than complex
 Complex if better than complicated
 Readability counts
 Explicit is better than implicit

A simple Program to print “Hello World”

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 7


Python Programming

Python Operators
In Python programming, Operators in general are used to perform operations on values and
variables. These are standard symbols used for the purpose of logical and arithmetic operations. In
this article, we will look into different types of Python operators.
 OPERATORS: These are the special symbols. E.g.- +, *, /, etc.
 OPERAND: It is the value on which the operator is applied.
Types of Operators in Python
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators
6. Identity Operators and Membership Operators
Arithmetic Operators in Python:
Python Arithmetic operators are used to perform basic mathematical operations like addition,
subtraction, multiplication, and division.

Operator Description Syntax

+ Addition: adds two operands x+y

– Subtraction: subtracts two operands x–y

* Multiplication: multiplies two operands x*y

/ Division (float): divides the first operand by the second x/y

// Division (floor): divides the first operand by the second x // y

Modulus: returns the remainder when the first operand is divided by


% x%y
the second

** Power: Returns first raised to power second x ** y

Comparison operators in Python:


Relational operators are used for comparing the values. It either returns True or False according to
the condition. These operators are also known as Comparison Operators.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 8


Python Programming

Operator Description Syntax

> Greater than: True if the left operand is greater than the
x>y
right

< Less than: True if the left operand is less than the right x<y

== Equal to: True if both operands are equal x == y

!= Not equal to – True if operands are not equal x != y

>= Greater than or equal to: True if left operand is greater than
x >= y
or equal to the right

<= Less than or equal to: True if left operand is less than or
x <= y
equal to the right

Logical Operators in Python:


Operators are used to perform operations on values and variables. These are the special symbols
that carry out arithmetic and logical computations. The value the operator operates on is known
as Operand.
Table of Content
 Logical operators
 Logical AND operator
 Logical OR operator
 Logical NOT operator

In Python, Logical operators are used on conditional statements (either True or False). They
perform Logical AND, Logical OR and Logical NOT operations.

DATA STRUCTURES IN PYTHON

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 9


Python Programming

Data Structures are a way of organizing data so that it can be accessed more efficiently
depending upon the situation. Data Structures are fundamentals of any programming language
around which a program is built. Python helps to learn the fundamental of these data structures in a
simpler way as compared to other programming languages.

In this, we will discuss the Data Structures in the Python Programming Language and how they
are related to some specific Python Data Types. We will discuss all the in-built data structures like
list tuples, dictionaries, etc. as well as some advanced data structures like trees, graphs, etc.

PYTHON LISTS: -
A list is a data-structure, or it can be considered a container that can be used to store multiple data
at once. The list will be ordered and there will be a definite count of it. The elements are indexed
according to a sequence and the indexing is done with 0 as the first index. Each element will have a
distinct place in the sequence and if the same value occurs multiple times in the sequence, each will
be considered separate and distinct element. A more detailed description on lists and associated data-
types are covered in this tutorial.

In this tutorial you will come to know of the about how to create python lists and the common
paradigms for a python list.

Lists are great if you want to preserve the sequence of the data and then iterate over them later for
various purposes. We will cover iterations and for loops in our tutorials on for loops.

How to create a list: -

To create a list, you separate the elements with a comma and enclose them with a bracket “[]”.

For example, you can create a list of company names containing “hacker earth”, “google”,
“Facebook”. This will preserve the order of the names.

>>> companies = [“hackerearth”, “google”, “facebook”]


>>> # get the first company name
>>> print(companies[0])
‘hackerearth’
>>> # get the second company name
>>> print(companies[1])
‘google’
>>> # get the third company name
>>> print(companies[2])
‘facebook’
>>> # try to get the fourth company name
>>> # but this will return an error as only three names
>>> # have been defined.
>>> print(companies[3])
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
IndexError: list index out of range

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 10


Python Programming

Trying to access elements outside the range will give an error. You can create a two-dimensional list.
This is done by nesting a list inside another list. For example, you can group “hacker earth” and
“Paytm” into one list and “tcs” and “cts” into another and group both the lists into another “master”
list.

>>> companies = [[“hackerearth”, “paytm”], [“tcs”, “cts”]]


>>> print(companies)
[[‘hackerearth’, ‘paytm’], [‘tcs’, ‘cts’]]

Methods over Python Lists: -


Python lists support common methods that are commonly required while working with lists. The
methods change the list in place. (More on methods in the classes and objects tutorial). In case you
want to make some changes in the list and keep both the old list and the changed list, take a look at
the functions that are described after the methods.

How to add elements to the list: -

 list.append(elem) – will add another element to the list at the end.

How to remove elements from the list: -

 list.remove(elem) – will search for the first occurrence of the element in the list and will then remove
it.

For example, if you have a list of languages with elements [‘haskell’, ‘clojure’, ‘apl’, ‘scala’,
‘F#’] and you want to remove scala, you can use the remove method.

>>> langs.remove(“scala”)
>>> print(langs)
[‘haskell’, ‘clojure’, ‘apl’, ‘F#’]

 list.pop() – will remove the last element of the list. If the index is provided, then it will remove
the element at the particular index. For example, if you have a list [5, 4, 3, 1] and you apply the
method pop, it will return the last element 1 and the resulting list will not have it.

Other useful list methods: -

 list.sort() – will sort the list in-place.

For example, if you have an unsorted list [4,3,5,1], you can sort it using the sort method.

 list.reverse() – will reverse the list in place

For example, if you have a list [1, 3, 4, 5] and you need to reverse it, you can call the reverse method.

Functions over Python Lists: -

 You use the function “len” to get the length of the list.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 11


Python Programming

For example, if you have a list of companies [‘hackerearth’, ‘google’, ‘facebook’] and you want the
list length, you can use the len function.

>>> # you have a list of companies


>>> companies = [‘hackerearth’, ‘google’, ‘facebook’]

>>> # you want the length of the list


>>> print(len(companies))
3

 If you use another function “enumerate” over a list, it gives us a nice construct to get both the
index and the value of the element in the list.

For example, you have the list of companies [‘hackerearth’, ‘google’, ‘facebook’] and you want the
index, along with the items in the list, you can use the enumerate function.

>>> # loop over the companies and print both the index as youll as the name.
>>> for indx, name in enumerate(companies):
... print(“Index is %s for company: %s” % (indx, name))
...
Index is 0 for company: hackerearth
Index is 1 for company: google
Index is 2 for company: facebook

In this example, you use the for loop. For loops are pretty common in all programming languages that
support procedural constructs. You can head over to A complete theoretical reference to loops in C to
have a deeper understanding of for loops. Also look at the tutorial on loops in Python in Python
Control Structures tutorial.

 sorted function will sort over the list

Similar to the sort method, you can also use the sorted function which also sorts the list. The
difference is that it returns the sorted list, while the sort method sorts the list in place. So this function
can be used when you want to preserve the original list as well.

>>> # initialise a list


>>> some_numbers = [4,3,5,1]
>>> # get the sorted list
>>> print(sorted(some_numbers))
[1, 3, 4, 5]
>>> # the original list remains unchanged
>>> print(some_numbers)
[4, 3, 5, 1]

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 12


Python Programming

PYTHON DICTIONARY: -
Dictionary in Python is a collection of keys values, used to store data values like a map, which,
unlike other data types which hold only a single value as an element.
Example of Dictionary in Python
Dictionary holds key:value pair. Key-Value is provided in the dictionary to make it more
optimized.
Creating a Dictionary: -
In Python, a dictionary can be created by placing a sequence of elements within curly {} braces,
separated by ‘comma’. Dictionary holds pairs of values, one being the Key and the other
corresponding pair element being its Key:value. Values in a dictionary can be of any data type and
can be duplicated, whereas keys can’t be repeated and must be immutable.
Note – Dictionary keys are case sensitive, the same name but different cases of Key will be treated
distinctly.

# Creating a Dictionary
# with Integer Keys
Dict = {1: ‘Geeks’, 2: ‘For’, 3: ‘Geeks’}
print(“\nDictionary with the use of Integer Keys: “)
print(Dict)

# Creating a Dictionary
# with Mixed keys
Dict = {‘Name’: ‘Geeks’, 1: [1, 2, 3, 4]}
print(“\nDictionary with the use of Mixed Keys: “)
print(Dict)

Output:
Dictionary with the use of Integer Keys:

{1: ‘Geeks’, 2: ‘For’, 3: ‘Geeks’}

Dictionary with the use of Mixed Keys:

{‘Name’: ‘Geeks’, 1: [1, 2, 3, 4]}

Dictionary can also be created by the built-in function dict(). An empty dictionary can be created
by just placing to curly braces{}.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 13


Python Programming

Time complexity: O(len(dict))


Space complexity: O(n)

Nested Dictionary: -

Adding elements to a Dictionary

Addition of elements can be done in multiple ways. One value at a time can be added to a
Dictionary by defining value along with the key e.g. Dict[Key] = ‘Value’. Updating an
existing value in a Dictionary can be done by using the built-in update() method. Nested
key values can also be added to an existing Dictionary.
Note- While adding a value, if the key-value already exists, the value gets updated
otherwise a new Key with the value is added to the Dictionary.
Complexities for Adding elements in a Dictionary:
Time complexity: O(1)/O(n)
Space complexity: O(1)
Accessing elements of a Dictionary: -
In order to access the items of a dictionary refer to its key name. Key can be used inside square
brackets.

There is also a method called get() that will also help in accessing the element from a dictionary.
This method accepts key as argument and returns the value.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 14


Python Programming

Complexities for Accessing elements in a Dictionary:


Time complexity: O(1)
Space complexity: O(1)

Dictionary methods: -

Method Description

Remove all the elements from the


dic.clear()
dictionary

dict.copy() Returns a copy of the dictionary

dict.get(key, default = “None”) Returns the value of specified key

Returns a list containing a tuple for


dict.items()
each key value pair

Returns a list containing dictionary’s


dict.keys()
keys

Updates dictionary with specified key-


dict.update(dict2)
value pairs

Returns a list of all the values of


dict.values()
dictionary

Remove the element with specified


pop()
key

Removes the last inserted key-value


popItem()
pair

dict.setdefault(key,default= set the key to the default value if the


“None”) key is not specified in the dictionary

returns true if the dictionary contains


dict.has_key(key)
the specified key.

used to get the value specified for the


Dict.get(key, default = “None”)
passed key.

PYTHON TUPLES: -

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 15


Python Programming

Python Tuple is a collection of objects separated by commas. In some ways, a tuple is similar
to a Python list in terms of indexing, nested objects, and repetition but the main difference between
both is Python tuple is immutable, unlike the Python list which is mutable.
Creating Python Tuples
There are various ways by which you can create a tuple in Python. They are as follows:
 Using round brackets
 With one item
 Tuple Constructor
Create Tuples using Round Brackets ()
To create a tuple, we will use () operators.
What is Immutable in Tuples?
Tuples in Python are similar to Python lists but not entirely. Tuples are immutable and ordered and
allow duplicate values. Some Characteristics of Tuples in Python.
 We can find items in a tuple since finding any item does not make changes in the tuple.
 One cannot add items to a tuple once it is created.
 Tuples cannot be appended or extended.
 We cannot remove items from a tuple once it is created.
Accessing Values in Python Tuples: -
Tuples in Python provide two ways by which we can access the elements of a tuple.
 Using a positive index
 Using a negative index
Python Access Tuple using a Positive Index
Using square brackets, we can get the values from tuples in Python.
Access Tuple using Negative Index
In the above methods, we use the positive index to access the value in Python, and here we will use
the negative index within [].
Different Operations Related to Tuples:-
Below are the different operations related to tuples in Python:
 Concatenation
 Nesting
 Repetition
 Slicing
 Deleting
 Finding the length

 Multiple Data Types with tuples


 Conversion of lists to tuples

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 16


Python Programming

 Tuples in a Loop

Concatenation of Python Tuples


To Concatenation of Python Tuples, we will use plus operators (+).
Nesting of Python Tuples
A nested tuple in Python means a tuple inside another tuple.
Repetition Python Tuples
We can create a tuple of multiple same elements from a single element in that tuple.
Slicing Tuples in Python
Slicing a Python tuple means dividing a tuple into small tuples using the indexing method.
Deleting a Tuple in Python
In this example, we are deleting a tuple using ‘del’ keyword. The output will be in the form of error
because after deleting the tuple, it will give a NameError.
Note: Remove individual tuple elements is not possible, but we can delete the whole Tuple using
Del keyword.
Finding the Length of a Python Tuple
To find the length of a tuple, we can use Python’s len() function and pass the tuple as the
parameter.
Multiple Data Types With Tuple
Tuples in Python are heterogeneous in nature. This means tuples support elements with multiple
datatypes.
Converting a List to a Tuple
We can convert a list in Python to a tuple by using the tuple() constructor and passing the list as its
parameters.
Tuples in a Loop
We can also create a tuple with a single element in it using loops.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 17


Python Programming

PYTHON SETS: -
A Set in Python programming is an unordered collection data type that is iterable, mutable and has
no duplicate elements.
Set is represented by { } (values enclosed in curly braces)

The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for
checking whether a specific element is contained in the set. This is based on a data structure known
as a hash table. Since sets are unordered, we cannot access items using indexes as we do in lists.
Python Frozen Sets
Frozen sets in Python are immutable objects that only support methods and operators that produce
a result without affecting the frozen set or sets to which they are applied. It can be done with frozen
set () method in Python.
While elements of a set can be modified at any time, elements of the frozen set remain the same
after creation.

If no parameters are passed, it returns an empty frozen set.

Internal working of Set


This is based on a data structure known as a hash table. If Multiple values are present at the same
index position, then the value is appended to that index position, to form a Linked List.

In, Python Sets are implemented using a dictionary with dummy variables, where key beings the
members set with greater optimizations to the time complexity.

Set Implementation:

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 18


Python Programming

Sets with Numerous operations on a single Hash Table:

However, there are two major pitfalls in Python sets:


1. The set doesn’t maintain elements in any particular order.
2. Only instances of immutable types can be added to a Python set.
Time complexity of Sets

Operation Average case Worst Case

x in s O(1) O(n)

Union s|t O(len(s)+len(t))

Multiple
(n-1)*O(l) where l is
intersection
max(len(s1),..,len(sn))
s1&s2&..&sn

Difference s-t O(len(s))

Operators for Sets

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 19


Python Programming

Sets and frozen sets support the following operators:

Operators Notes

key in s containment check

key not in s non-containment check

s1 == s2 s1 is equivalent to s2

s1 != s2 s1 is not equivalent to s2

s1 <= s2 s1 is subset of s2

s1 < s2 s1 is proper subset of s2

s1 >= s2 s1 is superset of s2

s1 > s2 s1 is proper superset of s2

s1 | s2 the union of s1 and s2

s1 & s2 the intersection of s1 and s2

s1 – s2 the set of elements in s1 but not s2

s1 ˆ s2 the set of elements in precisely one of s1 or s2

PYTHON STRINGS: -

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 20


Python Programming

A String is a data structure in Python that represents a sequence of characters. It is an immutable data
type, meaning that once you have created a string, you cannot change it. Strings are used widely in
many different applications, such as storing and manipulating text data, representing names, addresses,
and other types of data that can be represented as text.

Creating a String in Python


Strings in Python can be created using single quotes or double quotes or even triple quotes. Let us
see how we can define a string in Python.
Example:
In this example, we will demonstrate different ways to create a Python String. We will create a
string using single quotes (‘ ‘), double quotes (” “), and triple double quotes (“”” “””). The triple
quotes can be used to declare multiline strings in Python.

Accessing characters in Python String


In Python, individual characters of a String can be accessed by using the method of Indexing.
Indexing allows negative address references to access characters from the back of the String, e.g. -1
refers to the last character, -2 refers to the second last character, and so on.
While accessing an index out of the range will cause an IndexError. Only Integers are allowed to
be passed as an index, float or other types that will cause a TypeError.

String Slicing
In Python, the String Slicing method is used to access a range of characters in the String. Slicing in
a String is done by using a Slicing operator, i.e., a colon . One thing to keep in mind while using
this method is that the string returned after slicing includes the character at the start index but not
the character at the last index.
Example:
In this example, we will use the string-slicing method to extract a substring of the original string.
The [3:12] indicates that the string slicing will start from the 3 rd index of the string to the 12 th index,
(12th character not including). We can also use negative indexing in string slicing.

Reversing a Python String


By accessing characters from a string, we can also reverse strings in Python. We can Reverse a
string by using String slicing method.
Example:
In this example, we will reverse a string by accessing the index. We did not specify the first two
parts of the slice indicating that we are considering the whole string, from the start index to the last
index.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 21


Python Programming

Deleting/Updating from a String


In Python, the Updation or deletion of characters from a String is not allowed. This will cause an
error because item assignment or item deletion from a String is not supported. Although deletion of
the entire String is possible with the use of a built-in del keyword. This is because Strings are
immutable, hence elements of a String cannot be changed once assigned. Only new strings can be
reassigned to the same name.
Updating a character
A character of a string can be updated in Python by first converting the string into a Python
List and then updating the element in the list. As lists are mutable in nature, we can update the
character and then convert the list back into the String.
Another method is using the string slicing method. Slice the string before the character you want to
update, then add the new character and finally add the other part of the string again by string
slicing.
Example:
In this example, we are using both the list and the string slicing method to update a character. We
converted the String1 to a list, changes its value at a particular element, and then converted it back
to a string using the Python string join() method.
In the string-slicing method, we sliced the string up to the character we want to update,
concatenated the new character, and finally concatenate the remaining part of the string.

Built-In Function Description

string.ascii_letters Concatenation of the ascii_lowercase and ascii_uppercase


constants.

string.ascii_lowercase Concatenation of lowercase letters

string.ascii_uppercase Concatenation of uppercase letters

string.digits Digit in strings

string.hexdigits Hexadigit in strings

string.letters concatenation of the strings lowercase and uppercase

string.lowercase A string must contain lowercase letters.

String.octdigits Octadigit in a string

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 22


Python Programming

Built-In Function Description

string.punctuation ASCII characters having punctuation characters.

String.printable String of characters which are printable

String.endswith() Returns True if a string ends with the given suffix otherwise
returns False

String.startswith() Returns True if a string starts with the given prefix


otherwise returns False

String.isdigit() Returns “True” if all characters in the string are digits,


Otherwise, It returns “False”.

String.isalpha() Returns “True” if all characters in the string are alphabets,


Otherwise, It returns “False”.

string.isdecimal() Returns true if all characters in a string are decimal.

str.format() one of the string formatting methods in Python3, which


allows multiple substitutions and value formatting.

String.index Returns the position of the first occurrence of substring in a


string

string.uppercase A string must contain uppercase letters.

string.whitespace A string containing all characters that are considered


whitespace.

string.swapcase() Method converts all uppercase characters to lowercase and


vice versa of the given string, and returns it

replace() returns a copy of the string where all occurrences of a


substring is replaced with another substring.

PYTHON LOOPS: -

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 23


Python Programming

Python Programming language provides the following types of loops to handle looping
requirements. Python provides three ways for executing the loops. While all the ways provide
similar basic functionality, they differ in their syntax and condition-checking time.

While Loop in Python


In python, a while loop is used to execute a block of statements repeatedly until a given condition
is satisfied. And when the condition becomes false, the line immediately after the loop in the
program is executed.
Syntax:
while expression:

statement(s)

All the statements indented by the same number of character spaces after a programming construct
are considered to be part of a single block of code. Python uses indentation as its method of
grouping statements.

Using else statement with While Loop in Python


The else clause is only executed when your while condition becomes false. If you break out of the
loop, or if an exception is raised, it won’t be executed.

Syntax of While Loop with else statement:


while condition:

# execute these statements

else:

# execute these statements

For Loop in Python


For loops are used for sequential traversal. For example: traversing a list or string or array etc. In
Python, there is “for in” loop which is similar to for each loop in other languages. Let us learn how
to use for in loop for sequential traversals.
Syntax:
for iterator_var in sequence:

statements(s)

It can be used to iterate over a range and iterators.

Example with List, Tuple, string, and dictionary iteration using For Loops in Python

We can use for loop to iterate lists, tuples, strings and dictionaries in Python

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 24


Python Programming

Iterating by the index of sequences

We can also use the index of elements in the sequence to iterate. The key idea is to first calculate
the length of the list and in iterate over the sequence within the range of this length.

Using else statement with for loop in Python


We can also combine else statement with for loop like in while loop. But as there is no condition in
for loop based on which the execution will terminate so the else block will be executed
immediately after for block finishes execution.

Nested Loops
Python programming language allows to use one loop inside another loop. Following section shows
few examples to illustrate the concept.

Syntax:
for iterator_var in sequence:

for iterator_var in sequence:

statements(s)

statements(s)

The syntax for a nested while loop statement in the Python programming language is as follows:

while expression:

while expression:

statement(s)

statement(s)

A final note on loop nesting is that we can put any type of loop inside of any other type of loop. For
example, a for loop can be inside a while loop or vice versa.

Loop Control Statements


Loop control statements change execution from their normal sequence. When execution leaves a
scope, all automatic objects that were created in that scope are destroyed. Python supports the
following control statements.

Continue Statement
the continue statement in Python returns the control to the beginning of the loop.
Break Statement
The break statement in Python brings control out of the loop.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 25


Python Programming

Pass Statement
We use pass statement in Python to write empty loops. Pass is also used for empty control
statements, functions and classes.
How for loop in Python works internally?
Before proceeding to this section, you should have a prior understanding of Python Iterators.

Firstly, lets see how a simple for loop looks like.

Here we can see the for loops iterates over iterable object fruit which is a list. Lists, sets,
dictionaries are few iterable objects while an integer object is not an iterable object. For loops can
iterate over any of these iterable objects.

Now with the help of the above example, let’s dive deep and see what happens internally here.

1. Make the list (iterable) an iterable object with help of the iter() function.
2. Run an infinite while loop and break only if the StopIteration is raised.
3. In the try block, we fetch the next element of fruits with the next() function.
4. After fetching the element we did the operation to be performed with the element. (i.e
print(fruit))

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 26


Python Programming

INTRODUCTION TO TECHNICAL HUB

Technical Hub is a Training institute which is part of Aditya Engineering College (A) located in
Aditya Educational Institutions at Surampalem. East Godavari in Andhra Pradesh 533437 India. It is
a specialized training centre which makes many of the Aditya Institutes students to learn various
technologies of computer, cloud services.

Babji Neelam is the C.E.O of the Technical Hub flatform who taken the idea to initiate a training
institute in Aditya Educational Institution at Surampalem.

In the year 2018 Babji Neelam initiated the idea of forming a training institute in Aditya Educational
Institutions, Surampalem. With a specialized incubation centre containing many facilities for the
students like high-speed internet connection, centralized Airconditioning and large class rooms with
many more features.

Technical hub is the one of the important flatform in providing software training for various roles in
software sector like coding, cloud services and web development. It is prestigious industry in that
sector. It is a good flatform and opportunity to students for learning various courses.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 27


Python Programming

CONCLUSION

This report gives the basic details of Technical Hub and different services provided by it. Mainly
Python Programming and its features are explained precisely. Python Programming plays an
important role in writing complicated codes. Python is noting but a programming language. This
report also includes both the major and minor concepts of Python programming.

In any internship, the goal is to learn something new. I can say that this is an understatement for my
summer internship program on Python programming at Technical Hub. While learning this I was able
to apply my previous experiences and knowledge that I have learned in the classroom and apply it to
real-world experience.

Understanding the syntax of Python is great and all, and Python by itself is indeed a great language,
but the fundamentals of Python aren't why Python is a successful language. There are plenty of fun-
to-write languages that are just like Python, such as Ruby, Julia, even R. What makes Python the
victor is the community and 3rd-party packages. While we can do a lot with just an installation of
Python and the standard library, we can do infinitely more with all of the 3rd party libraries out here.

ADITYA ENGINEERING COLLEGE(A) DEPT.OF EEE 28

You might also like