Introduction to Python
Session 2
What will you learn ?
• Introduction • Literals
• Introduction to Data Sets • Conditionals
• Concepts of Variables, Iterations & • Loops
Filtering • Functions
• Data Types • Lists & Tupules
• Sanity of Data • Sets & Dictionaries
• Introduction to Complex Data Types • File Handling
• Hands – On Python • Object Oriented Programming
Introduction to Data Sets
1. Data Sets –
1. Student Performance
2. Deck of Cards
2. Assignment 1-
1. Count the no of Cards in a Deck
2. Count the no of Red cards in a deck
3. Count the no of students in the data set
4. Count the no of students from North India
Assignment -1
1. Start :- the counting process
2. Iterate :- Going through the sequence of objects as you go on from one object to
another keep a count- It will always have a condition – till when to iterate …
3. Initialisation :- To keep a count – Initialise a variable = Say Count = 0
4. Increment :- Every time you move an object = you increment the count by 1
5. Stop - When you run out of cards
Assignment -2
1. Start :- the counting process
2. Iterate :- Going through the sequence of objects as you go on from one object to
another keep a count
3. Initialisation-1 :- To keep a count – Initialise a Variable1 = Say Count = 0
4. Initialisation-2:- Variable -2= Red Count=0
5. Increment :- Every time you move an object = you increment the Count by 1
6. Increment :- Every time you find a red card while moving an object = you
increment the Red Count by 1
7. Stop - When you run out of cards
Structured Thinking Approaches
The first approach to structured thinking is to put steps to the business problems
There are typically two ways to organize a process
• Flow Chart
• Steps Involved
• Pseudocode
• Flow Chart
• Pictorial representation of computational process
• Let us take an simple illustration:- Counting the number of cards
Flow Charts
• Node types
1. Process or Activity - Rectangular box Activities which
the value of a variable
2. Arrows indicate operation flow- Flow Line or the
order or the direction
3. Decision- Diamond Box- You take a decision in which
direction the program would take
4. Terminal- Oval shaped – Beginning or end of the
program
• Advantage
1. Visual representation of computation
2. Easy to understand
• Disadvantages
1. Size: Complex processes generate large flowcharts
2. Collaboration: Sharing pictures in editable format
3. Versions: Compare changes between flow charts
From Visuals to Steps & Words
Describe the process in words
Step 0 Start
Step 1 Initialize Count to 0
Step 2 Check cards in Pile 1
Step 3 If no more cards, go Step 8
Step 4 Pick a card X from Pile 1
Step 5 Move X to Pile 2
Step 6 Increment Count
Step 7 Go back to Step 2
Step 8 End
From Visuals to Steps & Words
• Succinct notation for computational processes
• Better textual representation for
• Conditional execution
• Step 3 If no more cards, go to Step 8
• Step 4 Pick a card X from Pile 1
• Repeated execution
• Step 2 Check cards in Pile 1
• ...
• Step 7 Go back to Step 2
General Flowchart
Start
Mark Items as Visited
Initialize
Update Variables
No - False
Unvisited
End
elements ?
Yes – True
Pick an Unvisited Element
Pseudocode
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Move X to Pile 2
Increment Count
}
End
Pseudocode
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Move X to Pile 2
Increment Count
}
End
Pseudocode
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Move X to Pile 2
Increment Count
}
End
1- Assign a Value to a Variable
Pseudocode
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Move X to Pile 2
Increment Count
}
End
1- Assign a Value to a Variable
2- Repeat steps while conditions holds
Pseudocode
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Move X to Pile 2
Increment Count
}
End
1- Assign a Value to a Variable
2- Repeat steps while conditions holds
3- Mark Start & End of A Repeated Block
Summary
• Flowcharts are easy to read, visual descriptions of procedures.
. . but they are cumbersome, hard to share and edit
• Writing down steps in text is an alternative
• Tune the notation to capture standard features
• Assigning values to variables
• Conditional execution
• Repeated execution
Resources
• [Link]
• [Link]
• [Link]
• [Link]
• [Link]
8
Things to initiated – Assignment
Set up & create the following accounts using SIES Id .
1. Kaggle account – [Link]
2. Replit account – [Link]
3. Stack Overflow Account – [Link]
4. GitHub- [Link]
5. Google Collab- with your g-mail account
6. Store the Data Sets for the forthcoming Sessions
1. Identify 3 Data Sets from Kaggle – as .Csv files