0% found this document useful (0 votes)
40 views

Programming Internship Documentation

Uploaded by

saiseshireddy09
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Programming Internship Documentation

Uploaded by

saiseshireddy09
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

LONG-TERM

INTERNSHIP
(On-Site/Virtual)

ANDHRA PRADESH
STATE COUNCIL OF HIGHER
EDUCATION
(A STATUTORY BODY OF GOVERNMENT OF ANDHRA PRADESH)
PROGRAM BOOK FOR

LONG-TERMINTERNSHIP
(Onsite/Virtual)

Challa Sai Kowndinya

Vignan’s Lara Institute of Technology & Science

21FE1A0531

Cisco Networking Academy,


Corporate Affairs,
Cisco Systems India Pvt Ltd.

2024-2025
An Internship Report on

Programming Essentials in Python

Submitted in accordance with the requirement for the degree of

BACHELOR OF TECHNOLOGY
in

Computer Science and Engineering

Submitted by

Challa Sai Kowndinya


(21FE1A0531)

Under the Faculty Guidance of

Ms. Asha Priyadarshini .M

Department of Computer Science & Engineering


Student’s Declaration

I, Challa Sai Kowndinya, a student of Bachelor of Technology, Reg. No.

21FE1A0531of the Department of Computer Science and Engineering, Vignan’s Lara

Institute of Technology & Science, do here by declare that I have completed the

mandatory internship in Programming Essentials in Python from / / to

/ / under the Guidance of Ms. Asha Priyadarshini .M, Department of

Computer Science and Engineering, Vignan’s Lara Institute of Technology & Science.

(Student Signature and Date)

Faculty Guide Head of the Department


Ms. Asha Priyadarshini .M Dr. K. Venkateswara Rao

External Examiner

4
Certificate from Intern Organization

4
5
fhfh

6
Acknowledgements

The satisfaction that accompanies the successful completion of any task would be
incomplete without the mention of people whose ceaseless cooperation made it
possible, whose constant guidance and encouragement crown all efforts with
success.

We are grateful to Ms. ASHA PRIYADARSHINI .M, M. Tech., Professor,


Department of Computer Science and Engineering for guiding through this
internship and for encouraging right from the beginning of the internship till
successful completion of the Internship. Every interaction with him was an
inspiration.

We thank Dr. K. VENKATESWARA RAO, M. Tech., Ph. D., Professor & HoD,
Department of Computer Science and Engineering for support and valuable
suggestions.

We also express our thanks to Dr. K. PHANEENDRA KUMAR, Principal,


Vignan’s Lara Institute of Technology & Science for providing the resources to
carry out the Internship.

We express our sincere thanks to our beloved Chairman Dr. LAVU RATHAIAH
for providing support and stimulating the environment for developing the
internship.

We also place our floral gratitude to all other teaching and lab technicians for their
constant support and advice throughout the Internship.

7
CONTENTS

1 Student Declaration
2 Certificate from Intern Organization
3 Acknowledgments
4 Overview of the Organization
5 Programming Essentials in Python

8
OVERVIEW OF THE ORGANIZATION

Cisco Systems, Inc. is a multinational technology headquartered in San Jose,


California, USA. Founded in 1984 by Leonard Bosack and Sandy Lerner, Cisco has
grown into one of the world's largest and most influential networking hardware,
software, and services companies. Cisco's vision centers around enabling the seamless
connectivity of people, devices, applications, and data to drive innovation,
productivity, and sustainable growth. The company aims to be the global leader in
networking solutions, empowering individuals, businesses, and communities to thrive
in a digitally connected world.

Vision:
Cisco Systems, Inc. envisions a digitally connected world where people, devices,
applications, and data seamlessly interact to drive innovation, productivity, and
sustainable growth. As a global leader in networking solutions, Cisco is committed to
empowering individuals, businesses, and communities to thrive in this interconnected
landscape. The company's vision encompasses a future where connectivity is
ubiquitous, reliable, and secure, fostering collaboration, creativity, and prosperity
across all sectors of
society.

Team and Infrastructure:


With tens of thousands of employees worldwide, Cisco attracts top talent from
a variety of disciplines, including engineering, software development, marketing, and
customer support. Cisco's team is driven by a passion for technology and to solving
complex challenges, working together to deliver innovative networking solutions.
Cisco's infrastructure spans the globe, comprising a comprehensive network of
research and development facilities, manufacturing plants, sales offices, data centers,
and service centers.

9
CHAPTER: PROGRAMMING ESSENTIALS IN PYTHON
Python is a computer programming language often used to build websites and
software, automate tasks, and analyze data. Python is a general-purpose language, not
specialized for any specific problems, and used to create various programmes. This
versatility and its beginner-friendliness have made it one of the most used
programming languages today. In 2020, more than one-third of Indian IT
professionals said Python was their preferred programming language. It continues to
top lists of the most desired programming languages in the country.

Python has become one of the most popular programming languages in recent
years. It's been used in everything from machine learning to building websites and
software testing. Developers and non- developers alike find it useful.

Python is commonly used for developing websites and software, task


automation, data analysis, and data visualisation. Since it’s relatively easy to learn,
Python has been adopted by many non-programmers, such as accountants and
scientists, for a variety of everyday tasks, like organizing finances.

What can you do with Python? Some things include:


 Data analysis and machine learning
 Web development
 Automation or scripting
 Software testing and prototyping

10
ACTIVITY LOG FOR THE FIRST WEEK

Day Person
In-
Brief description of the daily Learning Outcome
& Charge

Date Activity Signature

Day – 1 Computer Programming How a computer


program works

Day - 2 About natural and


Natural languages vs.
programming
programming languages
languages

Day – 3 Elements of
Programming Language
programming language

Advantages and
Day – 4 disadvantages of both
Compilation vs. Interpretation
compilation and
interpretation

Day – 5 Python Importance of Python

Day–6 How to write and run


Python Program a program

11
WEEKLY REPORT
WEEK – 1 (From Dt ………..….. to Dt.................)

Objective of Activity Done:


 The fundamentals of computer programming.
 The difference between compilation and interpretation.
 The basic information about Python and what distinguishes its different versions.

Detailed Report:
Python is a widely-used, interpreted, object-oriented, and high-level programming
language with dynamic semantics, used for general-purpose programming. And while
you may know the python as a large snake, the name of the Python programming
language comes from an old BBC television comedy sketch series called Monty
Python's Flying Circus.

Here are some key components and concepts:


 Natural language vs. Programming language: Natural languages are spoken
by people, while programming languages are intended for machines.

 What makes a language: Each language consists of the elements like alphabet,
lexis, syntax and semantics.

 Source code and Source file: A program written in a high-level programming


language is called a source code (in contrast to the machine code executed by
computers). Similarly, the file containing the source code is called the source
file.

 Compilation vs. Interpretation: The process of translating source code written


in a high- level programming language into a lower-level language, such as
machine code, that can be executed by a computer is called as compilation. An
interpreter reads a program line by line, reading every expression and gives
output if the program is correct. It stops/gives error when it encounters the first
mistake in any line of code. This process is interpretation.

 There is more than one python: There are two main kinds of Python, called
Python 2 and Python 3. Python 2 is an older version of the original Python. Its
development has since been intentionally stalled, although that doesn't mean that
there are no updates to it. Python 3 is the newer (to be precise, the current)
version of the language. It's going through its own evolution path, creating its
12
own standards and habits.

13
ACTIVITY LOG FOR THE SECOND WEEK

Day Person In-


& Brief description of the daily Learning Outcome Charge

Date Activity Signature

How to use the


Day – Print() function
print()
1
function

How to use the


Day - 2 Print() function
print()
function

Learnt about
Day – Variables and Data Types
variables and various
3
data types

Learnt about
Day - 4 Variables and Data Types
variables and various
data types
How to perform
Day – Operators and operations different
5 operations using
operators
How to perform
Arithmetic Operators and different
Day–6
operations operations using
arithmetic
operators

14
WEEKLY REPORT
WEEK – 2 (From Dt………..….. to Dt.................)

Objective of Activity Done:


 How to write and run simple Python programs.
 Understanding the concepts of data types, variables and basic operations.
 How to perform basic input and output operations.

Detailed Report:

Python variables are like containers used to store data of various data types. Data
types are the classification or categorization of data items. It represents the kind of
value that tells what operations can be performed on a particular data. Since
everything is an object in Python programming, Python data types are classes and
variables are instances (objects) of these classes.

Here are some key components and concepts:

 Print() function: The print() function prints the specified message to the
screen, or other standard output device. The message can be a string, or any
other object, the object will be converted into a string before written to the
screen.
 Literals: Literals are notations for representing some fixed values in code.
Python has various types of literals - for example, a literal can be a number
(numeric literals, e.g., 123), or a string (string literals, e.g., "I am a literal.").
 Data Type: Python Data Types are used to define the type of a variable. It
defines what type of data we are going to store in a variable. The following
are the standard or built-in data types in Python: Numeric (Integer, Complex
Number, Float), Sequence Type (Strings, List, Tuple), Boolean, Set,
Dictionary.
 Python Operators: Operators are used to perform operations on variables
and values.
 Python Arithmetic Operators: + (addition), - (subtraction), *
(multiplication), / (classic division ‒ always returns a float), % (modulus ‒
divides left operand by right operand and returns the remainder of the
operation, e.g., 5 % 2 = 1),

15
ACTIVITY LOG FOR THE THIRD WEEK

Day Person
In-
& Brief description of the daily Learning Outcome Charge
Activity
Date Signature

Day – 1 bool() function Converts a value into its


boolean representation

Making decisions in
Day - 2 Simple if, if-else Statements Python

More compled decision


Day – 3 Nested if, elif-ladder
making in Python

More concise way to


Day – 4 match case
handle decision making

How to repeat code


Day – 5 Iterative Statements - For Loop
execution using loops

How to repeat code


Iterative Statements - While
Day–6 execution using loops -
Loop
II

16
WEEKLY REPORT
WEEK – 3 (From Dt………..….. to Dt.....................)

Objective of Activity Done:


 Use case of the bool() function
 Understanding the flow of control of the program by leveragint the if, else, nested-if
else
 Understanding the working of the iterative statements

Detailed Report:

 bool() function: The bool() function in Python converts a value to a Boolean,


returning True or False. It returns False for values like 0, None, empty sequences
(e.g., [], (), {}), and False itself. For all other values, it returns True.
 Conditional Statements: Conditional Statements are statements in Python that
provide a choice for the control flow based on a condition. It means that the control
flow of the Python program will be decided based on the outcome of the condition.
 Loops or Iteration: Statements in Programming are helpful when we need a specific
task in repetition. They’re essential as they reduce hours of work to seconds. We can
run a single statement or set of statements repeatedly using a loop command. It has 2
types of loops. They are for loop and while loop.
 Match Case: The match case statement in Python is initialized with the match
keyword followed by the parameter to be matched. Then various cases are defined
using the case keyword and the pattern to match the parameter. The “_” is the
wildcard character that runs when all the cases fail to match the parameter value.

17
ACTIVITY LOG FOR THE FOURTH WEEK

Person
Day In-
& Brief description of the Learning Outcome Charge
daily
Date Activity Signature

Day – Lists Learnt about lists


1

List operations and


Day – List Operations
modifications
2

Day – Logical Operators Learnt logical operators


3

Day – Logical Operators Learnt logical operators


4

Day – Bitwise Operators Learnt bitwise operators


5

Day–6 Bitwise Operators Learnt bitwise operators

18
WEEKLY REPORT
WEEK – 4 (From Dt………..….. to Dt......)

Objective of Activity Done:


 Using Python Lists.
 Various logical operators and their usage.
 Bitwise operators and their usage.

Detailed Report:

 List: The list is a type of data in Python used to store multiple objects. It is an
ordered and mutable collection of comma-separated items between square
brackets.
 Lists can be indexed and updated.
 Lists can be nested.
 List elements and lists can be deleted.
 The len() function may be used to check the list's length.
 Python supports the following logical operators:
and → if both operands are true, the condition is true, e.g., (True and True) is
True,
or → if any of the operands are true, the condition is true, e.g., (True or False) is
True,
not → returns false if the result is true, and returns true if the result is false, e.g.,
not True is False.
 Bitwise operators to manipulate single bits of data. The following sample
data: & does a bitwise and, e.g., x & y = 0, which is 0000 0000 in binary,
| does a bitwise or, e.g., x | y = 31, which is 0001 1111 in binary,
˜ does a bitwise not, e.g., ˜ x = 240*, which is 1111 0000 in binary,
^ does a bitwise xor, e.g., x ^ y = 31, which is 0001 1111 in binary,
>> does a bitwise right shift, e.g., y >> 1 = 8, which is 0000 1000 in binary,
<< does a bitwise left shift, e.g., y << 3 = , which is 1000 0000 in binary.

19
ACTIVITY LOG FOR THE FIFTH WEEK

Day Brief description of the Person In-


Learning Outcome
& daily Activity Charge
Date Signature

code structuring and the


Day – 1 Functions
concept of function;

function invocation and


Day - 2 Parameterized Function returning a result from a
function;

name scopes and


Day – 3 Types of Functions
variable shadowing;

Day – 4 Recursion Calling a function itself

tuples and their


Day – 5 Tuple – Introduction, Declaration purpose, constructing
and using tuples;
tuples and their
Uses of Tuples, Operations,
Day–6 purpose, constructing
Methods
and using tuples;

20
WEEKLY REPORT
WEEK – 5 (From Dt.....................to Dt...................)

Objective of Activity Done:

 Functions
 Parameterized Function
 Types of Functions
 Recursion
 Tuple – Introduction, Declaration
 Uses of Tuples, Operations, Methods

Detailed Report:

 A function is a block of code that performs a specific task when the function is
called (invoked). You can use functions to make your code reusable, better
organized, and more readable. Functions can have parameters and return values.
 There are at least four basic types of functions in Python
 built-in functions which are an integral part of Python (such as the print() function).
You can see a complete list of Python built-in functions
at https://docs.python.org/3/library/functions.html the ones that come from pre-
installed modules (you'll learn about them in the Python Essentials 2 course).
 User-defined functions which are written by users for users - you can write your
own functions and use them freely in your code,
 Tuples are ordered and unchangeable (immutable) collections of data. They can be
thought of as immutable lists. They are written in round brackets.
 Python Tuple is a collection of Python Programming objects much like a list. The
sequence of values stored in a tuple can be of any type, and they are indexed by
integers. Values of a tuple are syntactically separated by ‘commas‘. Although it is
not necessary, it is more common to define a tuple by closing the sequence of values
in parentheses. This helps in understanding the Python tuples more easily.

21
ACTIVITY LOG FOR THE SIXTH WEEK

Day Person
In-
Learning Outcome
& Brief description of the daily Charge
Date Activity Signature

Day – Dictionaries Learnt dictionaries


1
Sample dictionary
Day - 2 Dictionary usage
usage

Day – Dictionary operations Dictionary operations


3

Exceptions in Python: Python exception


Day –
Introduction support
4

Day – Types of exceptions Learnt exception types


5

Learnt exception
Day–6 Exception handling
handling

22
WEEKLY REPORT
WEEK – 6 (From Dt………..….. to Dt...................)

Objective of Activity Done:


 Understanding dictionaries in Python.
 Dictionary methods.
 Python exception handling and types.

Detailed Report:
 Dictionaries are unordered, changeable (mutable), and indexed collections of data.
(In Python 3.6x dictionaries have become ordered by default.
 Each dictionary is a set of key: value pairs.
 If you want to access a dictionary item, you can do so by making a reference to its
key inside a pair of square brackets or by using the get() method.
 If you want to change the value associated with a specific key, you can do so by
referring to the item's key name.
 You can use the for loop to loop through a dictionary.
 If you want to loop through a dictionary's keys and values, you can use
the items() method.
 To check if a given key exists in a dictionary, you can use the in keyword.
 You can use the del keyword to remove a specific item, or delete a dictionary. To
remove all the dictionary's items, you need to use the clear() method.
 To copy a dictionary, use the copy() method.
 In Python, there is a distinction between two kinds of errors:
 Syntax errors (parsing errors), which occur when the parser comes across a
statement that is incorrect
 Exceptions, which occur even when a statement/expression is syntactically correct;
these are the errors that are detected during execution when your code results in an
error which is not unconditionally fatal.

23
ACTIVITY LOG FOR THE SEVENTH WEEK

Day Person
In-
& Brief description of the daily Charge
Learning Outcome
Date Activity Signature

Modules Introduction Learnt modules


Day – 1

Learnt importing
Modules Importing
Day - 2 modules

Packages Introduction Learnt packages


Day – 3

Packages Structure and


Day – 4 Importing Learnt package creation

pip Introduction Learnt pip


Day – 5

pip Usage Learnt pip usage


Day–6

24
WEEKLY REPORT
WEEK – 7 (From Dt………..….. to Dt...................)

Objective of Activity Done:


 Modules and importing.
 Packages and their usage.
 Familiarizing with pip.

Detailed Report:

 If you want to import a module as a whole, you can do it using the import
module_name statement. You are allowed to import more than one module at once
using a comma-separated list.
 If a module is imported in the above manner and you want to access any of its
entities, you need to prefix the entity's name using dot notation.
 You are allowed not only to import a module as a whole, but to import only
individual entities from it. In this case, the imported entities must not be prefixed
when used.
 You can change the name of the imported entity "on the fly" by using the as phrase of
the import.
 A function named dir() can show you a list of the entities contained inside an
imported module.
 The math module couples more than 50 symbols (functions and constants) that
perform mathematical operations (like sine(), pow(), factorial()). The random module
groups more than 60 entities designed to help you use pseudo-random numbers.
The platform module contains about 70 functions which let you dive into the
underlaying layers of the OS and hardware.
 A package is a container which enables the coupling of several related modules under
one common name. Such a container can be distributed as-is (as a batch of files
deployed in a directory sub-tree) or it can be packed inside a zip file.
 A Python file named init .py is implicitly run when a package containing it is
subject to import, and is used to initialize a package and/or its sub-packages (if any).
The file may be empty, but must not be absent.
 To make use of PyPI the specialized tool has been created and its name is pip.

25
ACTIVITY LOG FOR THE EIGHTH WEEK

Day Person In-


& Brief description of the daily Learning Charge
Outcome
Activity
Date Signature

Characters, strings and


Introduction to Strings coding standards;
Day – 1

Strings vs. lists –


similarities and
Day - 2 String Immutability differences;

Day – 3
String Methods String Methods

Day – 4 String Methods


String Methods

Day – 5 Problems on Strings Practice Problems

Day–6 Problems on Strings Practice Problems

26
WEEKLY REPORT

WEEK – 8 (From Dt………..….. to Dt...................)

Objective of Activity Done:


 Introduction to Strings
 String Immutability
 String Methods

Detailed Report:
 Introduction of Strings: A String is a data structure in Python Programming that
represents a sequence of characters. It is an immutable data type, meaning that
once you have created a string, you cannot change it. Python String 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.

 Computers store characters as numbers. There is more than one possible way of
encoding characters, but only some of them gained worldwide popularity and are
commonly used in IT: these are ASCII (used mainly to encode the Latin
alphabet and some of its derivates) and UNICODE (able to encode virtually all
alphabets being used by humans).

 A number corresponding to a particular character is called a codepoint.

 UNICODE uses different ways of encoding when it comes to storing the


characters using files or computer memory: two of them are UCS-4 and UTF-8
(the latter is the most common as it wastes less memory space).

27
ACTIVITY LOG FOR THE NINTH WEEK

Day Person
In-
Learning Outcome
& Brief description of the daily Charge
Date Activity Signature

Understanding
Day – 1 Exceptions Introduction
Exceptions

Day - 2 Exceptions Usage Learnt exception usage

Learnt exception
Day – 3 Exception handling
handling

Day – 4 Exception hierarchy Understanding


exception hierarchy

Exception handling
Day – 5 Exception branching with exceptional
hierarchy

Day–6 Exception definition New exception creation

28
WEEKLY REPORT
WEEK – 9 (From Dt………..….. to Dt...................)

Objective of Activity Done:


 Understanding exceptions.
 Exception hierarchy.
Detailed Report:

 An exception is an event during program execution caused by an


abnormal situation. The exception should be handled to avoid the
termination of the program. The part of your code that is suspected of
being the source of the exception should be put inside the try branch.
 When the exception happens, the execution of the code is not terminated, but
instead jumps into the except branch. This is the place where the handling of
the exception should take place.
 If you need to handle more than one exception coming from the
same try branch, you can add more than one except branch, but you have to
label them with different exception names.
 At most, one of the except branches is executed – none of the branches is
performed when the raised exception doesn't match any of the specified
exceptions.
 You cannot add more than one anonymous (unnamed) except branch after the
named ones.
 All the predefined Python exceptions form a hierarchy, i.e. some of them
are more general (the one named Base Exception is the most general one)
while others are more or less concrete (e.g. Index Error is more concrete
than Look up Error).
 You should avoid placing more general exceptions before more specific
ones inside the same except branch sequence.

29
ACTIVITY LOG FOR THE TENTH WEEK

Brief description of the Person In-


Day & Date daily activity Learning Outcome Charge
Signature

Day – 1 Introduction to OOP Uses of OOP

Reusability of the
Day - 2 Inheritance
methods and properties

Behaving differently
Day – 3 Polymorphism based on different
scenarios

Restricting the direct


Day – 4 Encapsulation access to private
variables

Hiding unnecessary
Day – 5 Abstraction complexity from the
user

contains information
about the error,
Day–6 Exceptions as objects including its type and
the state of the program
when the error occurred

30
WEEKLY REPORT
WEEK – 10 (From Dt.....................to Dt..................)

Objective of Activity Done:


 Introduction to OOP
 Inheritance
 Polymorphism
 Encapsulation
 Abstraction

Detailed Report:
 A class is an idea (more or less abstract) which can be used to create a number of
incarnations – such an incarnation is called an object.

 When a class is derived from another class, their relation is named inheritance. The
class which derives from the other class is named a subclass. The second side of this
relation is named superclass. A way to present such a relation is an inheritance
diagram, where:
 Super classes are always presented above their subclasses;
 relations between classes are shown as arrows directed from the subclass toward
its superclass.
 Objects are equipped with:
 a name which identifies them and allows us to distinguish between them;
 a set of properties (the set can be empty)
 a set of methods (can be empty, too).

31
ACTIVITY LOG FOR THE ELEVENTH WEEK

Day Person
In-
Learning Outcome
& Brief description of the daily Charge
Date Activity Signature

Learnt about magic


Day – Magic methods Introduction
methods
1

Magic methods
Day - 2 Magic methods definition
definition

Learnt attribute
Day – Attribute resolution order
resolution order
3

Day – super() function Learnt super() function


4

Day – Class hierarchy Class hierarchy


5

Learnt overriding in
Day–6 Overriding methods
classes

32
WEEKLY REPORT

WEEK – 11 (From Dt………..….. to Dt.................)

Objective of Activity Done:


 Exploring str methods.
 super() function for inheritance.
 Exception class hierarchy.
Detailed Report:
 A method named str () is responsible for converting an object's contents into a (more
or less) readable string. You can redefine it if you want your object to be able to present
itself in a more elegant form.

 A function named is sub class (Class_1, Class_2) is able to determine if Class_1


is a subclass of Class_2.

 A function named is instance (Object, Class) checks if an object comes from an


indicated class.

 A operator called is checks if two variables refer to the same object.

 A parameter less function named super () returns a reference to the nearest superclass
of the class.

 Methods as well as instance and class variables defined in a superclass are automatically
inherited by their subclasses.

 In order to find any object/class property, Python looks for it inside:

o the object itself;

o all classes involved in the object's inheritance line from bottom to top;

o if there is more than one class on a particular inheritance path, Python scans
them from left to right;

o if both of the above fail, the Attribute Error exception is raised.

 If any of the subclasses defines a method/class variable/instance variable of the same


name as existing in the superclass, the new name overrides any of the previous
instances of the name.

33
ACTIVITY LOG FOR THE TWELTH WEEK

Day Person In-


& Brief description of the Learning Outcome Charge
daily
Date Activity Signature

Introduction to the
Day – Filesystem API working with files
1 using the files module

Working with read()


Day - 2 Reading from a file function

Working with write()


Day – Writing to a file
function
3

Subprocess creation
Day – OS module
and output management
4

Studying with Unix


Day – Datetime module
epoch
5

Formating various raw


Day–6 Working with datetime datetime strings

34
WEEKLY REPORT
WEEK – 12 (From Dt………..….. to Dt..................)

Objective of Activity Done:


 Filesystem API
 Reading from a file
 Writing to a file
 OS module
 datetime module
 Working with datetime

Detailed Report:
 A file needs to be open before it can be processed by a program, and it
should be closed when the processing is finished.
 Opening the file associates it with the stream, which is an abstract
representation of the physical data stored on the media. The way in which
the stream is processed is called open mode. Three open modes exist:
o read mode – only read operations are allowed;
o write mode – only write operations are allowed;
o update mode – both writes and reads are allowed.
 Depending on the physical file content, different Python classes can be
used to process files. In general, the BufferedIOBase is able to process
any file, while TextIOBase is a specialized class dedicated to processing
text files (i.e. files containing human-visible texts divided into lines using
new-line markers). Thus, the streams can be divided into binary and text
ones.
 The following open() function syntax is used to open a file:
o open(file_name, mode=open_mode, encoding=text_encoding)
 The invocation creates a stream object and associates it with the file
named file_name, using the specified open_mode and setting the specified
text_encoding, or it raises an exception in the case of an error
 Three predefined streams are already open when the program starts:
o sys.stdin – standard input;
o sys.stdout – standard output;
o sys.stderr – standard error output.
 The IOError exception object, created when any file operations fails
(including open operations), contains a property named errno, which
contains the completion code of the failed action. Use this value to
diagnose the problem.

35

You might also like