Beginning with
Programming
Prof. Rushikesh V. Kolhe
Phd Pursuing, M.Tech Civil CM
Assistant Professor
Department of Civil Engineering
Sanjivani College of Engineering, Kopargaon
Contents:
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and gain an appreciation of the Python shell.
• Use calculations, variables, strings, lists, if statements, and more.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
Contents:
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and gain an appreciation of the Python shell.
• Use calculations, variables, strings, lists, if statements, and more.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
What is computer
• Aprogramming?
set of commands a computer understands – like a recipe.
• Computer programs can help cure diseases; drive cars; create video
games; make animated movies/graphics; build websites and apps; and
much more.
• Basic coding concepts are used by most every program and most every
programmer.
What is a programming
language?
• A programming language is a set of rules that provides a way of telling
a computer:
• What operations to perform
• Communicating an algorithm
• Receives an input from the user and generates an output.
• A programming language is a system for describing a computation
(math) or algorithms (logic) in a machine-readable and human-
readable form.
• Has words, symbols, and grammatical rules (natural language)
• Grammatical rules = syntax
• Each language has a different set of syntax rules
• Has semantics (meaning)
Slide courtesy of Brian Pichman
Why learn to
•Why not? code?
•Learn the importance of clarity/brevity of expression.
•Be able to think and problem solve more accurately.
•Have a better understanding of how technology works.
•Create a tool that can make life easier and/or fun.
What is Python and what
•can
Developedit do?
in 1989 by Guido Van Rossum
• Python was named after Monty Python’s Flying Circus TV show.
• Python is an interpreted high-level programming language for general-
purpose programming.
• Interpreted means that the interpreter (embedded in Idle) can execute
instructions directly without compiling.
• Compiling is a translation from source code to a lower-level language (e.g.,
machine code)
• High-level programming resembles human languages, not machine languages, and
are easier to read and write.
• Python has helped build some famous applications like YouTube,
DropBox, Instagram, BitTorrent, Spotify, Reddit etc.
Why do people use Python?
1) Easy to Learn and Use
Python is easy to learn and use. It is developer-friendly and high level programming
language.
2) Expressive Language
Python language is more expressive means that it is more understandable and
readable.
3) Interpreted Language
Python is an interpreted language i.e. interpreter executes the code line by line at a time.
This makes debugging easy and thus suitable for beginners.
4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, Unix and Macintosh
etc. So, we can say that Python is a portable language.
5) Free and Open Source
Python language is freely available at offical web address.The source-code is also available.
Why do people use Python?
6) Object-Oriented Language
Python supports object oriented language
7) Extensible
It implies that other languages such as C/C++ can be used to compile the code and thus it can
be used further in our python code.
8) Large Standard Library
Python has a large and broad library and prvides rich set of module and functions for rapid
application development.
9) GUI Programming Support
Graphical user interfaces can be developed using Python.
10) Integrated
It can be easily integrated with languages like C, C++, JAVA etc.
Python helped build
Quora too!
Read more: https://goo.gl/nr8BZk
Raspberry Pi (Python)
programming
Blinking LED code at: http://goo.gl/O3yozd
Installing
Python
https://www.python.org/downloads
https://docs.python.org/3.6/tutorial/index.html
IDLE - Integrated DeveLopment
Environment)
The third line is a print statement (function), which prints the stored name “Hello World.”
Calculations,
variables,
strings, and
lists.
Revie
w Lists:
Calculations: Variables:
20 * 6.789 chad = 100 music_list = ['The Beatles', 'Led
sam = Zeppelin' , 'Pink Floyd' , 'Mr.
250 – 45 Bungle']
chad
40 / 8.9 print(sam) print(music_list)
5 + 30 * 20
myscore = 1000 print(music_list[3])
(5 + 30) * 20 message = 'I scored %s
((5+30) * 20) / 10 points' music_list.append(
'The Clash')
print(message %
myscore) >>>
print(music_list)
Source: https://goo.gl/JS73o4
This function is defined by the def statement.
myfunc is the name of the function.
myname is the parameter (i.e., a variable
while the function is being used).
‘Chad’ is a string.
Functio
ns
•A function is a piece of code that tells Python to do something. It is a type
of procedure or routine and usually returns a value. Functions are used
to utilize code in more than one place in a program.
• A procedure preforms an operation, but typically doesn’t provide a value.
• Most languages have pre-built or pre-defined functions in its library.
• For instance, the “delete” function means to “remove”. You don’t have to code what
“remove” does; only what to remove.
Defining a function in Python
If
statement
s,
functions,
loops,
modules.
Revie
w
If statements: Functions: Loops: Modules:
If age > 20: range() for x in range(0,5): turtle
list() print(“Hello https://docs.py
== equal to
Pen world”) tho n.org/3/py-
!= not equal to modindex.html
https://docs.pyt
>= Greater than or equal to
<= Less than or equal to hon.org/3/libr
y/functions.html
ar
Creating Simple
Programs
Explore …
A place to “host and review code, manage
projects, and build software alongside
millions of other developers.”
Play Tic Tac Toe
Against AI
Code available at https://github.com/geekcomputers/Python
Flow
Chart
Image source: https://goo.gl/mo7NY
Creating
Madlibs
variable function string
Some great resources to help you
learn to code
Read more at http://goo.gl/Hgy16A
.com
Learn to code interactively, for
free.
http://www.oeconsortium.org/
https://www.coursera.org/
https://www.codeavengers.com/
https://www.khanacademy.org
https://teamtreehouse.com/
https://www.codeschool.com/
http://coderdojo.
com
http://www.slideshare.net/chadmairn
@cmairn
Contact me!