Escolar Documentos
Profissional Documentos
Cultura Documentos
Programming 07 Hrs
• General problem solving concepts :
•
What is problem?
The problem is defined as the objective or the specific output that we want to attain;
through a sequence of steps and activities and, specific input.
Basic Skills required to be an Engineer
• Technical
• Problem solving
• Quick learning
• Applied Knowledge
• Soft skill
Example problem in daily life
Students do science experiment
Mechanics repair a
broken car Workers goes to work
Problem?
3 Type of clock? NA
7 Pasted on wall? NA
8 Purpose of clock? NA
9 Shape of clock? NA
Exercise
• Create computer application to issue book from college library
How to solve
the problem?
Problem Solving Definition
A Systematic approach to defining problem(question or situation that presents
uncertainty or difficulty) and creating a vast number of possible solutions without judging these
solutions.
Problem Solving in Everyday Life
There are six step in problem solving:
Problem Solving in Everyday Life
Can I skip
the step?
List
instructions
Identify the Understand Identify Select the Evaluate
the problem that enable the
problem alternative best way you to solve solution
the problem
Group Activities
In in group of 4 persons, think a problems in your daily life at home, office,
park, school, shopping mall or wherever your go. Please explain how you solve
the problem using the six steps of problem solving.
Types of problems
❖ Well-defined problems
Ex: list out presidents of India since 1947
❖ Poorly defined problems
Ex: How to improve communication?
Software
Design
Development
LifeCycle: Implementation
Testing
Maintenance
Problem Design tools
i. Algorithm
ii. Flowchart
iii. Pseudo code
Algorithm
Finite set of instructions for performing a particular task, instructions
are nothing but statements in simple English Language.
Top-own
Bottom-
own
• Control flow statement:
1)Sequence- Each step executed in specified order.
Ex. Algorithm to add 2 numbers
Step 1: Start
Step 2: Read the first no in variable num1
Step 3: Read the second no in variable num2
Step 4: If num1=num2
print “EQUAL”
Else
print ”UNEQUAL”
Step 5: Stop
Exercise
Process/calculations Decision
input
output
Connector
• Addition of 2 no
• Calculate average of 2 no
• Calculate sum of first 10 numbers
• Comparison of 2 no.
3. Pseudo code
• Compact and informal high level description of algorithm that uses
structural conventions of programming language.
• Ideal pseudo code describes entire logic of program which directly
translated to program.
• Meant for human reading than machine reading so it omits details
which are not essential for human
E.g. variable declaration
• Should not contain keyword of computer language.
• Purpose- enhance human understandability of solution
• No std define to write pseudocode
Calculate total price
• Take integer price
• Read sales tax rate
• Calculate tax= price of item * sales tax rate
• Calculate total prize= tax + price of items
• Print total prize
•The language places strong emphasis on code reliability and simplicity so that the
programmers can develop applications rapidly
• Python supports cross platform development and is available through open source.
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
History of Python
• Developed by Guideo Van Rossum at Netherland
• Python 1.0 released in 1994 with features like lambda, map filter
• Python 2.0 released in 2000 with added features like list,
comprehensions, garbage collection etc
• Python 2.7 released in December 3,2018 for rectifying fundamentals
of flow of languages
Python Versions
➢ Release dates for the major and minor versions:
➢ Python 1.0 - January 1994
➢ Python 1.5 - December 31, 1997
➢ Python 1.6 - September 5, 2000
➢ Python 2.0 - October 16, 2000
➢ Python 2.1 - April 17, 2001
➢ Python 2.2 - December 21, 2001
➢ Python 2.3 - July 29, 2003
➢ Python 2.4 - November 30, 2004
➢ Python 2.5 - September 19, 2006
➢ Python 2.6 - October 1, 2008
➢ Python 2.7 - July 3, 2010
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
Why do people use Python…?
The following primary factors cited by Python users seem to be these:
Python is object-oriented Structure supports such concepts as polymorphism,
operation overloading, and multiple inheritance.
Indentation is one of the greatest future in Python.
It's free (open source)
Downloading and installing Python is free and easy Source code is easily accessible
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
Features of Python
• Simple
• Easy to Learn
• Versatile
• Free and Open Source
• High level Language
• Interactive
• Portable
• Object Oriented
• Interpreted
• Dynamic
• Extensible
• Embeddable
• Easy Maintenance
• Robust
• Multi-threaded
• Garbage Collection
Applications
• Desktop Applications
• Image Processing Applications
• Scientific and Computational Applications
• Games
• Enterprise &Business Applications
• Operating systems
• Language Development
• Web Development
• 3-D software
• Teaching
Future of Python
• Top Companies Embracing Python Programming Language
Not only small companies but even top companies are using Python as their
business application development.
• Central Intelligence Agency (CIA) is using Python to maintain their websites.
• Web Development:
• Machine Learning: (Suppose you have to develop a code to determine the
picture whether it is a car or a bike. ML typically implements an algorithm that
automatically detects a pattern in the given inputs.)
• Data Analysis and Data Visualization:
it also helps in the analysis of a large amount of data through its high
performance libraries and tools.
Python Code Execution
Python’s traditional runtime execution model: source code you type is translated to byte
code, which is then run by the Python Virtual Machine. Your code is automatically
compiled, but then it is interpreted.
print(“Hello Python”)
print(“Its nice learning Python”)
print(“Python is easy to learn”)
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
Literal Constants
• Number- numeric value
• Integer ex.80
• long integer ex. 53563385246L
• Float point ex.4.35
• Complex number ex.a+bi
• String-group of characters
Ex. ‘Hello’ “Hello”
Print( type(a))
>>>a = 2.0
>>>a = 1+2j
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
Operations on numbers
10+7 =17 5*3.0= 15.0
• Division by zero
15/0 generate error
• Quotient & Reminder
15/3= 5.0 15%3=0
15//3=5
• Exponential
5**3=125
String
Smt. Kashibai Navale College of Engg, Pune. Savitribai Phule Pune University - 2019-20
>>>’navin’ + ’navin’ o/p: ‘navinnavin’
>>>’navin’*5
>>>print(‘navin\nsingh’)
>>>print(r’ navin\nsingh’)
• s = 'Hello world!’
• # s[4] = ? print("s[4] = ", s[4])
• # Strings are immutable in Python s[5] =?
Variables
• Store piece of information in a variable
• It is part of memory
• Assigned with name
• Are identifiers
print(name+”is”+age+”years old”)
Comments(#)
• Non-executable statements in program
• Interpreters ignores the comments
• # is used
Ex.
#program to display Hello
print(“Hello”) #display hello
A=10 #initialization
Reserved words
• Words with predefined meaning
• Cannot be used for naming identifiers
age=21
print(age) #error of indentation
Operators &expression
• operators + - * / etc
• operands numbers, variables
ex. sum= a + b
1. arithmetic 5. Unary
2. comparison 6. Bitwise
3. assignment 7. Membership
4. logical 8. Identity
Arithmetic
+, -, *, /, %, **, //
ex.
Operation output
40/10 4.0
40%10 0
12//5 2
12/5 2.4
2**3 8
Comparison
== a==b False
!= a!=b True
• Conversion:
expressions, Expressions in Python
An expression is a combination of symbols that evaluates to a value.
Expressions, most commonly, consist of a combination of operators
and operands
example of expression –
4 + (3 * k)
What is mixed-type expressions, arithmetic expression