Introduction To Computing Lab#1

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 31

Introduction to Computing Lab

Course (Lab):
–Introduction to Computing

Instructor:
Engr. Qazi Salman Khalid

Department of Industrial Engineering


Outlines

• HEC Curriculum for Introduction to Computing Lab

• Course Contents

• CLO’s

• Grading & Attendance Policy

• Intro. to Software Package

• Riddles

• Practice of Excel
HEC Curriculum Guidelines 2017
• Introduction to Computing 3(2, 1)
• Objective:
• To give working knowledge & skills of coding ( MATLAB/ Python etc.),
how to avoid common coding pitfalls, to use and create own functions and
classes. The course will enable students to recognize the advantages of
using pointers and references & to understand the fundamental ideas of
object oriented programming(OOP).
Course Contents

• Introduction to computer hardware and software


• Introduction to programming languages
• Equation solvers and procedural computations
• Constants and variables
• Arithmetic operations
• Intrinsic functions
• Algorithm design, and Pseudo codes
• IF statements, Do loop, While loop, Data files
• Formatted Input and Output, Logical and character data type
• Arrays: One-dimensional, Two dimensional
LAB CLO

PLOs
Course Learning Assessment Activities & Weight Taxonomy Addressed by
CLO No.
Outcomes (CLOs) Percentage Domain Course (PLO
No.)

To Practice python Modern


1 programming Lab Reports 100 C3 Tool Usage
software (5)
What will I be doing?
Work Weightage

Lab Work and OEL 10%

Lab Reports 10%

Presentations (2) 10%

Mid Term 20%

Final Term 50%


ATTENDANCE & DISCIPLINE POLICY
As per Industrial Engineering Department Policy and University of
Engineering and Technology Regulations, student with less than 75 %
attendance will not be allowed to sit in exam.
Note:
• Students are bound to submit the lab reports of each class in the next
working week.
• Students are bound to keep the checked lab reports, with them till the
declaration of results. They may be asked to bring it on the day of viva.
• In case of error in sessional marks, contact the respective teacher at
earliest.
• There will be no marks for the copied report/ test.
Lab Report Format

• Guidelines for Lab Report:- • Mention the objective of current lab


• Each lab report should have the following report
sections mentioned below: ▫ Problem Statement
• Includes question of the problem being
• Font format all over should be Times solved
New Roman ▫ Procedure
• Text alignment must be in justified form • Detail step wise procedure how you have
• Next paragraph space must be auto or 10 solved the problem
pt. ▫ Result and Discussion
• What are the results and discuss it
• Lab No. (Header) properly
• Title of Lab Report (Font size = 14 and ▫ Conclusion
Center of Page) • Concluding remarks regarding the lab
▫ Introduction (Font Size = 14) report and software
• Includes Brief introduction of the topic ▫ Comments
covered in the lab report (Font Size = 12) • Personal comments about the lab
▫ Objective
Lab Report Format Cont…
•Heading of tables should be on the top of table
Table 1.1 Heading of Table 1 in lab report 1

•Figures/diagram no. and details should be below the figure/diagram.

Figure 1.1 Tora first screens shot for beginners


Python
Python is an interpreted, high-level, general-purpose programming language.
Created by Guido van Rossum and first released in 1991.
Inspired by a funny drama serial Monty Python
Python Philosophy
Coherence
not hard to read, write and maintain
power

Scope
rapid development + large systems

Objects

Integration
hybrid systems

The order matters!

Scope of this course: Intended for people with no experience with


programming.
Using Python
• IDE (Integrated Development Environment) A set of tools used to help us
develop code.
• For now we can think of it as the program that runs our python code for
us.
• A free version is linked from the website. Let's see what it looks like.

The shell will interpret lines of python that we feed it.


Basic mathematical operations are part of python. So we can use python
as a calculator.
Python isn't very good at calculating

• You have multiplication, addition, subtraction, division and


powers (*,+,-,/,**) but sometimes the answers are weird.
• If you give python integers, it will assume that you want
integers back.
• For fractions, one uses floating point numbers. Python
interprets any number with a decimal in it as a float.
• Floats are only approximations of real numbers.
Python comes with a lot of stuff
• Beyond basic arithmetic there are lots of prebuilt functions in
Python.
• Some math ones like max and abs.
• But also other useful ones like dir and help
▫ Dir returns a list of functions that are available.
▫ Help returns information about a function or module
Variables
• A variable is a name that refers to a value.
• Variables let us store and reuse values in several places.
• But to do this we need to define the variable, and then tell it
to refer to a value.
• We do this using an assignment statement.
Assignment Statements
• Form: variable = expression
• An expression is a legal sentence in python that can be evaluated.
• What it does:
• Evaluate the expression on the RHS.(This value is a memory address)
• Store the memory address in the variable on the LHS.
• What this means is that a variable is a name and a memory address.
The name points to a memory address where the value is stored.
• This means that variables in python behave fundamentally differently
than variables in math.
Simple Case Studies- Riddles
(Just to click the mind)
Problem

 If all the below statement are true


1. Gianni was either in Italy or France in 1997.
2. If Gianni did not kill Versace, then Hilton must have killed him.
3. If Versace died of suffocation, then either Gianni killed him or
Versace committed suicide.
4. If Gianni was in Italy in 1997, then Gianni did not kill Versace.
5. Versace died of suffocation, but he did not kill himself.
Who killed Versace and where was Gianni in 1997 ?
Answer

• Gianni was in France in 1997 & he killed Versace.

Versace died of suffocation=>This information should lead


you to statement #3 next. From here you should gather that
Gianni killed Versace. Thus leading to statement #4, Gianni
was in France in 1997.
Age Problem
• Two old friends, Jack and Bill, meet after a long time.

Three kids
Jack: Hey, how are you, man?
Bill: Not bad, got married and I have three kids now.
Jack: That's awesome. How old are they?
Bill: The product of their ages is 72 and the sum of their ages
is the same as your birth date.
Jack: Cool..But I still don't know.
Bill: My eldest kid just started taking piano lessons.
Jack: Oh, now I get it but still in doubt.

How old are Bill's kids?


ANSWER

• 3,3,8
Lets break it down. The product of their ages is 72. So what
are the possible choices?
2, 2, 18 sum(2, 2, 18) = 22
2, 4, 9 sum(2, 4, 9) = 15
2, 6, 6 sum(2, 6, 6) = 14
2, 3, 12 sum(2, 3, 12) = 17
3, 4, 6 sum(3, 4, 6) = 13
3, 3, 8 sum(3, 3, 8 ) = 14
1, 8, 9 sum(1,8,9) = 18
1, 3, 24 sum(1, 3, 24) = 28
1, 4, 18 sum(1, 4, 18) = 23
1, 2, 36 sum(1, 2, 36) = 39
1, 6, 12 sum(1, 6, 12) = 19
• The sum of their ages is the same as your birth date. That could
be anything from 1 to 31 but the fact that Jack was unable to find
out the ages, it means there are two or more combinations with
the same sum. From the choices above, only two of them are
possible now.
2, 6, 6 sum(2, 6, 6) = 14
3, 3, 8 sum(3, 3, 8 ) = 14

Since the eldest kid is taking piano lessons, we can eliminate


combination 1 since there are two eldest ones. The answer is 3, 3
and 8.
Cipher Puzzle
• What does this message say?

GTYORJ OTE OUIABGT

Hint:
Count the letters and try splitting the letters up into
homogeneous groups.
• 'Great Job You Got It'
This type of code is known as a Caesar Box (Julius Caesar
was the first to write codes this way.) To decipher the
message, simply divide the code into four groups of four (you
can also divide them into groups such as 5 groups of 5 or 6
groups of 6 depending on the number of letters in the phrase),
and rearrange them vertically like this...

GTYO
RJOT
EOUI
ABGT
Then you read vertically column by column.
Math's Puzzle

• Using eight eights and addition only, can you make


1000?
Answer

• 888 + 88 + 8 + 8 + 8 = 1000
Problem on Excel # 1

• Students before entering the gymnasium pass Math, English and Russian.
Passing Score is 12. You should get at least 4 points in Mathematics for
admission. Create report on the receipt. It is necessary to compare the total
number of points with a passing grade. And check that math score was not
lower than "4". In the «result» column put "accepted" or "not accepted"
Problem on Excel # 2

• It is necessary to overestimate the trade balances. If the product is kept in


stock for more than 8 months we should reduce its price 2 times.

• If the product is stored for more than 8 months, the price is reduced 2
times. If it’s more than 5 months, but less than 8, it’s 1.5 times.
• If the value of the goods in the warehouse after the write-down was less
than 300 or the product is stored for longer than 10 months, it is written
off.
• Analyze the cost of cash balances after the devaluation. If the price of the
product after reassessment is below average values, we should write off
the product from the warehouse.
Problem on Excel # 3
• Many retailers and most wholesalers provide customers a price break
based on quantity. For example, a wholesaler may sell 1 to 10 T-shirts for
$10.50 each, and 11 to 25 T-shirts for $8.75 each. Use the following IF
statement formula to determine how much money you can save by
purchasing wholesale products for your company in bulk.
Determine the total invoice amount keeping in view the discounts. Also find
out the average cost of shopping carried out. Moreover, identify the
minimum and maximum cost of the items purchased. If possible, relate it to
the items.

You might also like