python intern notes-1
python intern notes-1
INTRODUCTION TO PYTHON
Python has grown in prominence in recent years as a robust and adaptable programming
language. Its simplicity, readability, and extensive ecosystem of libraries and frameworks make it
a preferred choice for developers across various domains.
Python’s simplicity and readability make it an ideal choice for both beginners and
experienced developers. Beginners can grasp the basics of the language quickly, while
experienced developers appreciate Python’s readability, which significantly reduces debugging
time and enhances code maintainability.
2. Extensive Standard Library
Python comes with an extensive standard library, which is a collection of modules and
packages that offer a wide range of functionalities. These modules and packages help simplify
complex tasks by providing pre-built functionalities, saving developers time and effort.
Python’s standard library includes modules and packages for regular expressions, GUI
programming, networking, data processing, and much more. This vast ecosystem ensures that
developers have access to a wide array of tools without the need for external dependencies. It
streamlines software development and ensures compatibility across different versions of Python.
By leveraging the functionalities provided by the standard library, developers can
significantly boost their productivity and reduce development time.
3. Cross-Platform Compatibility
Python’s cross-platform compatibility allows it to run seamlessly on different operating
systems such as Windows, macOS, and Linux. Developers can write their code once and deploy it
on multiple platforms, saving time and effort in application development.
if statement:
Allows you to execute a block of code only if a specified condition is true.
if-else statement:
Executes one block of code if the condition is true and another block if the condition is
false.
elif-statement:
if the previous conditions were not true, then try this condition.
CONTROL STATEMENTS:
Python programming language provides two types of loops – For loop and While loop to
handle looping requirements. a loop is a control structure that allows a set of instructions to be
repeatedly executed until a specific condition is met. Loops are essential for automating
repetitive tasks and iterating over sequences of data
while Loop
With the while loop we can execute a set of statements as long as a condition is true.
For Loops
A for loop is used for iterating over a sequence (that is either a list, a tuple, a
dictionary, a set, or a string).
break Statement
With the break statement we can stop the loop even if the while condition is true.
DAY 6 [11-01-2024]
FUNCTIONS
There are four collection data types in the Python programming language:
List is a collection which is ordered and changeable. Allows duplicate members.
Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
Set is a collection which is unordered, unchangeable*, and unindexed. No duplicate
members.
Dictionary is a collection which is ordered** and changeable. No duplicate members.
List
Lists are used to store multiple items in a single variable. Lists are one of 4 built-in data
types in Python used to store collections of data, the other 3 are Tuple, Set, and Dictionary, all with
different qualities and usage .
Ordered
When we say that lists are ordered, it means that the items have a defined order, and that
order will not change.
Changeable
The list is changeable, meaning that we can change, add, and remove items in a list after it
has been created.
Allow Duplicates
Since lists are indexed, lists can have items with the same value
Tuple
Tuples are used to store multiple items in a single variable.
A tuple is a collection which is ordered and unchangeable.
Tuples are written with round brackets.
Ordered
When we say that tuples are ordered, it means that the items have a defined order, and that
order will not change.
Unchangeable
Tuples are unchangeable, meaning that we cannot change, add or remove items after the
tuple has been created.
Allow Duplicates
Since tuples are indexed, they can have items with the same value.
Dictionary
Dictionaries are used to store data values in key:value pairs.
A dictionary is a collection which is ordered*, changeable and do not allow duplicate
Ordered or Unordered?
When we say that dictionaries are ordered, it means that the items have a defined order, and
that order will not change.
Unordered means that the items do not have a defined order, you cannot refer to an item by
using an index.
Changeable
Dictionaries are changeable, meaning that we can change, add or remove items after the
dictionary has been created.
Duplicates Not Allowed
Dictionaries cannot have two items with the same key.
Set
Sets are used to store multiple items in a single variable.
DAY 8[15-01-2024]
FILE HANDLING
File handling is an important part of any web application.
Python has several functions for creating, reading, updating, and deleting files.
File Handling
The key function for working with files in Python is the open() function.
The open() function takes two parameters; filename, and mode.
Open a File
The open() function returns a file object, which has a read() method for reading the content
of the file the read() method returns the whole text, but you can also specify how many characters
you want to return
Read Lines
You can return one line by using the readline() methodTo 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
Create a New File
To create a new file in Python, use the open() method, with one of the following parameters:
"x" - Create - will create a file, returns an error if the file exist
"a" - Append - will create a file if the specified file does not exist
"w" - Write - will create a file if the specified file does not exist
Delete a File
To delete a file, you must import the OS module, and run its os.remove() function
DAY 10 [17-01-2024]
MACHINE LEARNING
Data Visualization
In today’s world, a lot of data is being generated on a daily basis. And sometimes
to analyze this data for certain trends, patterns may become difficult if the data is in its
raw format. To overcome this data visualization comes into play. Data visualization
provides a good, organized pictorial representation of the data which makes it easier to
understand, observe, analyze. In this tutorial, we will discuss how to visualize data
using Python.
Python provides various libraries that come with different features
for visualizing data. All these libraries come with different features
and can support various types of graphs. In this tutorial, we will be discussing four such
libraries.
Matplotlib
Seaborn
Bokeh
Plotly
DAY 19[30-01-2024]
Data Analysis
What is Data Analysis?
Before jumping into the term “Data Analysis”, let’s discuss the term “Analysis”.
Analysis is a process of answering “How?” and “Why?”. For example, how was
the growth of XYZ Company in the last quarter? Or why did the sales of XYZ
Company drop last summer? So to answer those questions we take the data that we
already have. Out of that, we filter out what we need. This filtered data is the final
dataset of the larger chunk that we have already collected and that becomes the target
of data analysis. Sometimes we take multiple data sets and analyze them to find a
pattern.
For example, take summer sales data for three consecutive years. I found out if that
fall in sales last summer was because of any specific product that we were selling or if
it was just a recurring problem. It’s all about looking for a pattern. We analyze things or
events that have already happened in the past.
Why Data Analysis is important?
Let’s say you own a business and sell daily products. Your business model is
pretty simple. You buy products from the supplier and sell them to the customer.
Let’s assume the biggest challenge for your business is to find the right amount of
stock at the given time. You can’t stock excess dairy products as they are perishable
and if they go bad you can’t sell them, resulting in a direct loss for you. At the same
time, you can not understock as it may result in the loss of potential customers. But data
analytics can help you in predicting the strength of your customers at a given time.
Using that result, you can sufficiently stock your supplies, in turn, minimizing the loss.
In simple words, using data analysis, you can find out the time of the year when your
store has the least or the most customers. Using this info, you can stock your supplies
accordingly.
DAY 22 [02-02-2024]
Project Report
Objective
Classification Model to Identify Employee Attrition Project
Dataset description
Dataset source -
https://github.com/ybifoundation/Dataset/raw/main/EmployeeAttrition.csv
Dataset variables
1. AGE :
Numerical Value
2. ATTRITION : Employee leaving the company (0=no, 1=yes)
3. BUSINESS TRAVEL
: (1=No Travel, 2=Travel Frequently, 3=Tavel Rarely)
4. DAILY RATE : Numerical Value - Salary Level
5. DEPARTMENT :
(1=HR, 2=R&D, 3=Sales)
6. DISTANCE FROM HOME :
Numerical Value - THE DISTANCE FROM WORK TO HOME
7. EDUCATION Numerical Value
8. EDUCATION FIELD
(1=HR, 2=LIFE SCIENCES, 3=MARKETING, 4=MEDICAL SCIENCES, 5=OTHERS, 6=
TEHCNICAL)
9. EMPLOYEE COUNT
Numerical Value 10. EMPLOYEE NUMBER Numerical Value - EMPLOYEE ID
11. ENVIROMENT SATISFACTION Numerical Value - SATISFACTION WITH THE
ENVIROMENT
12. GENDER
(1=FEMALE, 2=MALE)
13. HOURLY RATE
Numerical Value - HOURLY SALARY
14. JOB INVOLVEMENT Numerical Value - JOB INVOLVEMENT
15. JOB LEVEL Numerical Value - LEVEL OF JOB
16. JOB ROLE (1=HC REP, 2=HR, 3=LAB TECHNICIAN, 4=MANAGER, 5= MANAGING
DIRECTOR, 6= REASEARCH
DIRECTOR, 7= RESEARCH SCIENTIST, 8=SALES EXECUTIEVE, 9= SALES
REPRESENTATIVE)
17. JOB SATISFACTION Numerical Value - SATISFACTION WITH THE JOB
18. MARITAL STATUS
(1=DIVORCED, 2=MARRIED, 3=SINGLE)
19. MONTHLY INCOME
20. MONTHY RATE
Numerical Value - MONTHLY SALARY
Numerical Value - MONTHY RATE
21. NUMCOMPANIES WORKED
Numerical Value - NO. OF COMPANIES WORKED AT
22. OVER 18 (1=YES, 2=NO)
23. OVERTIME (1=NO, 2=YES)
24. PERCENT SALARY HIKE 25. PERFORMANCE RATING
Numerical Value - PERCENTAGE INCREASE IN SALARY
Numerical Value - PERFORMANCE RATING
26. RELATIONS SATISFACTION Numerical Value - RELATIONS SATISFACTION
27. STANDARD HOURS
Numerical Value - STANDARD HOURS
28. STOCK OPTIONS LEVEL
Numerical Value - STOCK OPTIONS
29. TOTAL WORKING YEARS
Numerical Value - TOTAL YEARS WORKED
30. TRAINING TIMES LAST YEAR Numerical Value - HOURS SPENT TRAINING
31. WORK LIFE BALANCE Numerical Value - TIME SPENT BEWTWEEN WORK AND
OUTSIDE
32. YEARS AT COMPANY Numerical Value - TOTAL NUMBER OF YEARS AT THE
COMPNAY
33. YEARS IN CURRENT ROLE
Numerical Value -YEARS IN 34. CURRENT ROLE
34. YEARS SINCE LAST PROMOTION
Numerical Value - LAST PROMOTION
35. YEARS WITH CURRENT MANAGER
Numerical Value - YEARS SPENT WITH CURRENT MANAGER