0% found this document useful (0 votes)
41 views10 pages

Week 1-3 Summary Merged

This summary covers key concepts from weeks 1-3 of computational thinking: 1. Variables, iteration, filtering and multiple filtering were introduced as core concepts. Flowcharts and pseudocode were presented as ways to represent algorithms. Basic and subtype datatypes like boolean, integer, character and string were explained. 2. Conditional termination in iteration was discussed where the iteration stops when a desired data is found. Pseudocode was demonstrated as a textual representation of procedures. 3. Datasets can be presented as tables with attributes as columns and cards as rows. Techniques for systematic hypothesis verification and solving problems requiring multiple conditions were summarized. Procedures, parameters, interfaces and implementations were introduced.

Uploaded by

Alok Tripathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views10 pages

Week 1-3 Summary Merged

This summary covers key concepts from weeks 1-3 of computational thinking: 1. Variables, iteration, filtering and multiple filtering were introduced as core concepts. Flowcharts and pseudocode were presented as ways to represent algorithms. Basic and subtype datatypes like boolean, integer, character and string were explained. 2. Conditional termination in iteration was discussed where the iteration stops when a desired data is found. Pseudocode was demonstrated as a textual representation of procedures. 3. Datasets can be presented as tables with attributes as columns and cards as rows. Techniques for systematic hypothesis verification and solving problems requiring multiple conditions were summarized. Procedures, parameters, interfaces and implementations were introduced.

Uploaded by

Alok Tripathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Computational Thinking

A brief summary of Week 1

Variable: “A variable is a symbol which is used to represent a varying expression or quantity.”


OR
“A variable is a symbol used for representing an unspecified/unknown term.”

Example: 1. Counting number of cards present in the “Scores” dataset.


For that we created a variable called Count and initialized it to 0.
Then we add one to Count as we move a card from pile 1 to pile 2.
Count = 0 + 1 = 1

Iteration: “Repetition of a process”


OR
“Iteration is the repetition of a process in order to generate a sequence of outcomes”

Example: In the previous example we saw that every time we move cards from pile 1 to pile 2, we
add one to variable Count. This is nothing but an iteration.

Filtering: “Some specific decision”


OR
“In an iteration if we are only interested in specific item/data which are special to us and
not all items.”

Example: If we want to only count students from Chennai. In this case also we will move all cards
from pile 1 to pile 2 but we will add one to variable Count only when we find students from
Chennai.

Multiple filtering: For example if we want to find number of female students from Chennai.
Filters: (i) Checking gender: Male/Female
(ii) Checking City/Town
So, here total two filters are required to get the number of female students from Chennai.
Flowchart: “Pictorial representation of an algorithm”
OR
“A flowchart is a step-by-step diagrammatic representation using some defined shaped boxes to
solve a task.”

Rectangular box: Process or activity: Set of operations that change the value of data/variables

Arrow: Flowline: Shows the order of execution of the program steps

Diamond: Decision: Determines which path/direction the program will take (True/False)

Oval shaped box: Terminal: Indicates the start or end of the program.

Datatypes: (Lecture 1.7): “Defines the values that the variable can take, and the set of operations
that are permitted.”

Basic datatypes:

Boolean datatype: Range: Has only two values: True and False
Operation: AND, OR (Result type: Boolean) Result will be Boolean type
either True or False
Example:
If (X.Gender == ‘M’ AND X.City/Town == “Chennai”)

If (X.Gender == ‘M’ OR X.City/Town == “Chennai”)

Integer datatype: Range: ...., -3, -2, -1, 0, 1, 2, 3,.....


Operation: +, -, x, / (Result type: Integer)
<, >, == (Result type: Boolean)

Character datatype: Range: All alphanumeric: A, B,....Z, a, b,.....,z, 0, 1,.....,9


Special characters: ., $, #, @, .....
Operation: == (Result type: Boolean)
Example: ‘C’, ‘1’, ‘#’, ‘M’, ‘F’
*
String: Range: Any sequence of characters
Operation: == (Result type: Boolean)
Example: “IIT Madras”, “21F00055”, “can@1#23”

Subtype of basic datatypes: “Restrict the basic datatypes in terms of their ranges and constrained
on their operations”

Examples: Seq. No.: Ranges: 0, 1, 2, ..., Max (some reasonable number)


Operation: None of the integer operations make sense
: Boolean operations such as “==” can be performed
Marks: Ranges: 0, 1, ...., 100
Operation: Integer operation such as +, -

Transformation of sub-datatypes:
Date: 15 Jan : It is a string datatype.
Questions: What will be the date after 3 days?

We assume, 1 Jan : 0
2 Jan : 1
3 Jan : 2
--------
15 Jan : 14
-------
18 Jan: 17
-------
31 Dec : 364 (for non-leap year)

15 Jan Tranform 14
Integer operation

14 + 3

Print
18 Jan 17

Marks: Physics marks = 80.5


Mathematics marks = 90.5

We want to add the above two subject marks.

80.5 80.5x100 = 8050


90.5 90.5x100 = 9050

Then we performed integer operation, 8050 + 9050 = 17100


After that we need to bring back in original form by using “print” (defined in lecture)

print(17100) = 171.00
Lists and Records:

List: “A sequence of data elements of same or may be of different datatypes”


Example: (i) Subject marks obtained by Clarence: [63, 88, 73]

(ii) Details of Clarence: [9, “Clarence”, ‘M’, “6 Dec”, “Bengaluru”, 63, 88, 73, 224]

Record: “Stores data with multiple fields: each of which has a name and a value”
Example: A card of the Scores dataset.
{“Seq. No.”: 9, “Name”: “Clarence”, “DoB”: “6 Dec”, “Town/City”: “Bengaluru”,
“Mathematics”: 63, “Physics”: 88, “Chemistry”: 73, “Total”: 224}
A brief Summary of Week 2
Conditional termination in iteration:

Iteration: “Repetition of a process”


Termination in iteration: When Pile 1 is empty.
Conditional termination: Stops the iteration when a desired/specific data is found.

Check for desired card and Pile 2


Pile 1
Stops iteration when card is found

Examples: (i) Find a card in which all subject marks are above 90 from the “Scores” dataset.
(ii) Find a card in which three different category of items are present from the “Shopping
Bills” dataset.
Example:
A = True
while(Pile 1 has more cards and A){
Read card X
if(X.City == “Chennai”) {
A = False
}
Move card X to Pile 2
}

Pseudocodes: “Textual representation of procedures”


Example:
Start
Count = 0
while (Pile 1 has more cards) {
Pick a card X from Pile 1
Count = Count + 1
Move card X to Pile 2
}
End

Assigment statement: Count = 0


Sum = Sum + X.Mathematics

Equality statement: A == B

A=3
B=5
A == B --- False
B=3

A == B --- True
Conditional execution:
(i) One time: if (condition) {
---------
}

: if (condition) {
--------
}
else {
-------
}

(ii) Repeatedly: while (condition) {


-----------
}
A Brief Summary of week 3
1. Presentation of datasets in the form of a Table
• Each attribute/field is a column in the table (like: Card No., Gender, Total, etc)
• Each card is a row in the table.

Card No Name Gender DOB ---
0 Bhuvanesh M 7 Nov
1 Harish M 3 June

• Example: Sores dataset, Words dataset.

• Difficultify when a card has a variable number of attributes


Multiple rows:– duplication of data
Split as separate tables:- need to link via unique attributes
• Example: Shopping bill card
2. Below average students in two iterations (non-nested) and grade allocation
• First we compute average marks of some subject (1st iteration)
• And then in next iteration we compare each student marks with average marks of
that particular subject
Eg:
while(-----){
sum = sum + X.Maths
count = count + 1
}
avg = sum/count
while(-----)
if(not (X.Maths < avg)) ---- (not True) --- (False)
avgS = avgS + 1
}
}

Grade allocation: Find maximum and minimum marks of a subject


: Divide into garde bands and
: Count the numbers of students per grade bands

3. Systematic process of hypothesis verification

Example: To find the relation between word length and frequency


: Assumption – Long words >= 6 and Short words <= 5
- High frequency > 1 and Low frequency = 1

High frequency words

8 1

Short words Long words

15 23

Low frequency words

Hypothesis: (i) High frequency words tend to be short.


: (Words which have high frequeny and are short) / (Total high frequency words)
= 8 / (8 + 1) = 8 / 9 = 0.89
(ii) Low frequency words tend to be long?
4. Three prize problem
For getting prizes, it should satisfy three conditions:
(i) Should be in top three of total marks
(ii) Should be in a top three in at least one subjects
(iii) And there should be a representation of boys and girls

5. Introduction to procedures and parameters

• Procedure name: SumMaths


• Argument receives value: gen
• Calling procedure with a parameter: SumMaths (F)
• Argument variable is assigned parameter value
• Procedure call SumMaths(F) starts with, gen = F
• Procedure returns the value stored in Sum using
return(Sum)

Interface and Implementation:

Interface: Parameters to be passed


: Value to returned
: What side effects are possible

Implementation: Procedure definition

Eg:

Procedure pro1 (a, b)


return( 0.5*(a+b))
End proc1

Procedure pro2 ( a, b)
c=a+b
c = 0.5*c
return(c)
End proc2
Truth Tables:

(i) AND Table

A B A AND B
True True True
True False False
False True False
False False False

(ii) OR Table

A B A OR B
True True True
True False True
False True True
False False False

You might also like