SlideShare a Scribd company logo
Programming with
Python
                    Week 1
Dept. of Electrical Engineering and Computer Science
Academic Year 2010-2011
Why is it called Python?
Python’s Creator
Guido van Rossum


• Guido van Rossum, born in 31 January 1956, is a Dutch
  computer programmer, who invented the Python
  Programming Language. He is currently employed by
  Google, where he spends half of his time working on
  Python development.
It is called Python, because
• Guido was reading the
  published scripts from
  a BBC comedy
  series Monthy Python
  from the 1970s.
  Van Rossum thought
  he needed a name that
  was short, unique, and
  slightly mysterious, so he
  decided to call the language Python.
So what is Python?
• Python is an i. interpreted,
  ii. interactive,
  iii. object-oriented (OO)
  iv. programming language (PL).
• Python is a dynamically typed language.
• Python combines remarkable power with very clear
  syntax.
• Python is portable: it runs on many Unix variants, on the
  Mac, and on PCs under MS-DOS, Windows, Windows
  NT, and OS/2.
Python Gossip


• Python plays well with others.
• Python runs everywhere.
• Python is friendly, and easy to learn.
• Python is open.
“Python is ...”
•   “I love Python! Once you learn and use it, you don't want to go back to
    anything else. It allows fast development, is easy to test and debug, and
    comes with an extensive set of powerful features and libraries. For any
    skeptics out there, YouTube is developed entirely on Python and works
    beautifully!” said Özgür D. Şahin, Senior Software Engineer at YouTube.

•   “Python has been important part of Google since the beginning, and
    remains so as the system grows and evolves. Today, dozens of Google
    engineers use Python, and we are looking for more people with skills in
    this language,” said Peter Norvig, Director of Search Quality at Google,
    Inc.

•   “Python makes us extremely productive, and makes maintaining a large
    and rapidly evolving codebase relatively simple,” said Mark Shuttleworth
    at Thawte Consulting and Canonical Ltd., Ubuntu OS sponsor.
Is Python a good language
for beginner programmers?
• For a student, who has never programmed before, using
  a statically typed language seems unnatural. It slows the
  pace.
• Python has a consistent syntax and a large standard
  library. Students can focus on more important
  programming skills, such as problem decomposition and
  data type design, code reuse.
• Very early in the course, students can be assigned to
  programming projects that do something.
Is Python a good language
for beginner programmers?

• Python’s interactive interpreter enables students to test
  language features while they are programming.
• They can keep a window with the interpreter running,
  while they enter their program’s source in another
  window.
• Python is extremely practical to teach basic
  programming skills to students.
The name of our game
            is
learn & practice & dream
     with Python
1 Installing Python

• Open the /Applications folder.
• Open the Utilities folder.
• Double-click Terminal to open a terminal window and
  get to a command line.
• Type python at the command prompt.
• Make sure that you are running Python version 2.6.5.
1.8 Interactive shell

• Python leads a double life.
• It's an interpreter for scripts that you can run from the
  command line or by double-clicking the scripts. But
• It's also an interactive shell that can evaluate arbitrary
  statements and expressions.
• This is useful for debugging, quick hacking, and testing.
• Some people use the Python interactive shell as a
  calculator!
1.8 Interactive shell

• >>> 1+1
• >>> print ‘look mom, I am programming’
• >>> x=3
• >>> y=7
• >>> x+y
1.8 Interactive shell

• The Python interactive shell can evaluate arbitrary
  Python expressions, including any basic arithmetic
  expression (e.g., 1+1).
• The interactive shell can execute arbitrary Python
  statements (e.g., print).
• You can also assign values to variables, and the values
  will be remembered as long as the shell is open (but not
  any longer than that.)
2 First Python program




                     odbchelper.py
Run the program


• On UNIX-compatible systems (including Mac OS X),
  you can run a Python program from the command line:

  python odbchelper.py
Output of the program
2.2 Declaring Functions
• Python has functions like most other languages, but it
  does not have separate header files like C++ or
  interface/implementation section like Pascal.
                                                Function
  def buildConnectionString(params):           declaration


• Note that the keyword def starts the function
  declaration, followed by the function name, followed by
  the arguments in parentheses. Multiple arguments (not
  shown here) are separated with commas.
Python Functions
• Python functions do not specify the datatype of their return
  value; they don't even specify whether or not they
  return a value.
• Every Python function returns a value; if the function
  ever executes a return statement, it will return that
  value, otherwise it will return None, (Python null value).
• The argument, params, doesn't specify a datatype. In
  Python, variables are never explicitly typed. Python figures
  out what type a variable is and keeps track of it
  internally.
Python
--“dynamically typed”

• In Python, you never
  explicitly specify the datatype
  of anything.
• Based on what value you
  assign, Python keeps track
  of the datatype internally.
How Python datatypes
compare to other PLs
•   statically typed language: types are fixed at compile time. You are required to
    declare all variables with their datatypes before using them. Java and C are
    statically typed languages.

•   dynamically typed language: types are discovered at execution time; the
    opposite of statically typed. VBScript and Python are dynamically typed,
    because they figure out what type a variable is when you first assign it a
    value.

•   strongly typed language: types are always enforced. Java and Python are
    strongly typed. If you have an integer, you can't treat it like a string without
    explicitly converting it.

•   weakly typed language: types may be ignored; In VBScript, you can
    concatenate the string '12' and the integer 3 to get the string '123', then
    treat that as the integer 123, all without any explicit conversion.
Dynamic and Strong
• So Python is


  both dynamically typed, because it doesn't use explicit
  datatype declarations,

  and it is strongly typed, because once a variable has a
  datatype, it actually matters.
2.3 Documenting functions
                                                                            doc
•   You can document a Python function by giving it a doc string.          string




•   Triple quotes “1 ”2 ”3 signify a multiline string. Everything between the start
    and end quotes is part of a single string, including carriage returns and
    other quote characters.

•   Everything between the triple quotes is the functions’s doc string, which
    documents what the function does.

•   You should always define a doc string for your function.
2.4 Everything is an object


• Python functions have attributes and they are available
  at run time. A doc string is an attribute that is available at
  run time.
• A function is also an object.
Importing modules

• Import search path: when you try to import a
  module (a chunk of code that does something), Python
  uses the search path. Specifically, it searches in all
  directories defined in sys.path. This is a list and it is
  modifiable with standard list methods.
• >>> import sys
  (hint: sys is a module itself)
• >>> sys.path
Importing modules

• >>> sys.path.append(‘~/Dropbox/EECS Lisans/
  Programming with Python/Week 1/Code’)
• >>> import odbchelper
• >>> print odbchelper.__doc__
2.4 Everything is an object
                               two underscores

• Everything in Python is an object, and almost everything
  has attributes and methods.
• All functions have a built-in __doc__, which returns the
  doc string defined in the function’s source code.
• Everything is an object in the sense that it can be
  assigned to a variable or passed as an argument to a
  function.
• Strings are objects, Lists are objects, Functions are
  objects, Modules are objects, You are an object.
2.5 Indenting code

• Python functions have
  i. NO explicit begin or end, and
  ii. NO curly braces to mark where the function code
  starts and stops.

  The only delimiter is a colon (:) and

       the indentation of the code itself.
2.5 Indenting code

• Code blocks are defined by their indentation.
• By “code block”, I mean functions, if statements, for
  loops, while loops, and so forth.

• Indenting starts a code block. Un-indenting ends that
  code block.
• There are NO explicit braces, brackets, keywords used
  for marking a code block.
code blocks
code blocks




   one
argument
code blocks


  print statements can take any data type, including
  strings, integers, and other native datatypes. you can print
  several things on one line by using a comma-separated
  list of values
code blocks

 code
 block




 code
 block
code blocks

 code
 block
code blocks
• just indent and get on with your life.
• indentation is a language requirement. not a matter of
  style.
• Python uses carriage return to separate statements.
• Python uses a colon and indentation to separate code
  blocks.
  :
            ...
Back to your first program



                  code
                  block
Back to your first program



                            code
                            block
8hrs of sleep will make
you happier.

More Related Content

What's hot (19)

PPTX
Python Programming Language
Laxman Puri
 
PPTX
Python-00 | Introduction and installing
Mohd Sajjad
 
PDF
An Introduction to Python Programming
Morteza Zakeri
 
PDF
summer training report on python
Shubham Yadav
 
PPTX
Python Summer Internship
Atul Kumar
 
PPTX
Python presentation by Monu Sharma
Mayank Sharma
 
PPT
Python Programming ppt
ismailmrribi
 
PPTX
Beginning Python Programming
St. Petersburg College
 
PDF
Python indroduction
FEG
 
PPTX
Python Seminar PPT
Shivam Gupta
 
DOCX
Seminar report On Python
Shivam Gupta
 
PDF
Getting started with Linux and Python by Caffe
Lihang Li
 
PDF
Python Crash Course
Haim Michael
 
PDF
Introduction to python
Mohammed Rafi
 
PDF
Python final ppt
Ripal Ranpara
 
PPTX
Introduction to python for Beginners
Sujith Kumar
 
PPTX
Python Programming
shahid sultan
 
PPTX
Introduction to Python Programing
sameer patil
 
Python Programming Language
Laxman Puri
 
Python-00 | Introduction and installing
Mohd Sajjad
 
An Introduction to Python Programming
Morteza Zakeri
 
summer training report on python
Shubham Yadav
 
Python Summer Internship
Atul Kumar
 
Python presentation by Monu Sharma
Mayank Sharma
 
Python Programming ppt
ismailmrribi
 
Beginning Python Programming
St. Petersburg College
 
Python indroduction
FEG
 
Python Seminar PPT
Shivam Gupta
 
Seminar report On Python
Shivam Gupta
 
Getting started with Linux and Python by Caffe
Lihang Li
 
Python Crash Course
Haim Michael
 
Introduction to python
Mohammed Rafi
 
Python final ppt
Ripal Ranpara
 
Introduction to python for Beginners
Sujith Kumar
 
Python Programming
shahid sultan
 
Introduction to Python Programing
sameer patil
 

Viewers also liked (9)

KEY
What is open source?
Ahmet Bulut
 
KEY
Programming with Python - Week 3
Ahmet Bulut
 
PDF
Centro1807 marpegan tecnologia
Guillermo Barrionuevo
 
KEY
Programming with Python - Week 2
Ahmet Bulut
 
PPT
Upstreamed
jfetch01
 
KEY
Kaihl 2010
Ahmet Bulut
 
KEY
Virtualization @ Sehir
Ahmet Bulut
 
KEY
Startup Execution Models
Ahmet Bulut
 
What is open source?
Ahmet Bulut
 
Programming with Python - Week 3
Ahmet Bulut
 
Centro1807 marpegan tecnologia
Guillermo Barrionuevo
 
Programming with Python - Week 2
Ahmet Bulut
 
Upstreamed
jfetch01
 
Kaihl 2010
Ahmet Bulut
 
Virtualization @ Sehir
Ahmet Bulut
 
Startup Execution Models
Ahmet Bulut
 
Ad

Similar to Programming with Python: Week 1 (20)

PDF
Python Programing Bio computing,basic concepts lab,,
smohana4
 
PDF
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
 
PPT
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
 
PPT
Py-Slides-1.ppt1234444444444444444444444444444444444444444
divijareddy0502
 
PPT
program on python what is python where it was started by whom started
rajkumarmandal9391
 
PPT
Python slides for the beginners to learn
krishna43511
 
PPT
Python Over View (Python for mobile app Devt)1.ppt
AbdurehmanDawud
 
PPT
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
v65176016
 
PPTX
Introduction to Python Programming .pptx
NaynaSagarDahatonde
 
PPTX
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
sangeeta borde
 
PPTX
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
cigogag569
 
PPTX
Introduction to python
MaheshPandit16
 
PPTX
Python Programming 1.pptx
Francis Densil Raj
 
PDF
python-160403194316.pdf
gmadhu8
 
PPTX
Python
Shivam Gupta
 
PPTX
python presntation 2.pptx
Arpittripathi45
 
PDF
Pythonfinalppt 170822121204
wichakansroisuwan
 
PDF
Python for katana
kedar nath
 
PDF
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
PDF
Tutorial on-python-programming
Chetan Giridhar
 
Python Programing Bio computing,basic concepts lab,,
smohana4
 
Py-Slides- easuajsjsjejejjwlqpqpqpp1.pdf
shetoooelshitany74
 
notwa dfdfvs gf fdgfgh s thgfgh frg reggg
Godwin585235
 
Py-Slides-1.ppt1234444444444444444444444444444444444444444
divijareddy0502
 
program on python what is python where it was started by whom started
rajkumarmandal9391
 
Python slides for the beginners to learn
krishna43511
 
Python Over View (Python for mobile app Devt)1.ppt
AbdurehmanDawud
 
Py-Slides-1.pptPy-Slides-1.pptPy-Slides-1.pptPy-Slides-1.ppt
v65176016
 
Introduction to Python Programming .pptx
NaynaSagarDahatonde
 
2022-23TYBSC(CS)-Python Prog._Chapter-1.pptx
sangeeta borde
 
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
cigogag569
 
Introduction to python
MaheshPandit16
 
Python Programming 1.pptx
Francis Densil Raj
 
python-160403194316.pdf
gmadhu8
 
Python
Shivam Gupta
 
python presntation 2.pptx
Arpittripathi45
 
Pythonfinalppt 170822121204
wichakansroisuwan
 
Python for katana
kedar nath
 
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
manikamr074
 
Tutorial on-python-programming
Chetan Giridhar
 
Ad

More from Ahmet Bulut (12)

PDF
Nose Dive into Apache Spark ML
Ahmet Bulut
 
PDF
Data Economy: Lessons learned and the Road ahead!
Ahmet Bulut
 
PDF
Apache Spark Tutorial
Ahmet Bulut
 
PDF
A Few Tips for the CS Freshmen
Ahmet Bulut
 
PDF
Agile Data Science
Ahmet Bulut
 
PDF
Data Science
Ahmet Bulut
 
PDF
Agile Software Development
Ahmet Bulut
 
KEY
Liselerde tanıtım sunumu
Ahmet Bulut
 
KEY
Ecosystem for Scholarly Work
Ahmet Bulut
 
KEY
I feel dealsy
Ahmet Bulut
 
KEY
Bilisim 2010 @ bura
Ahmet Bulut
 
KEY
ESX Server from VMware
Ahmet Bulut
 
Nose Dive into Apache Spark ML
Ahmet Bulut
 
Data Economy: Lessons learned and the Road ahead!
Ahmet Bulut
 
Apache Spark Tutorial
Ahmet Bulut
 
A Few Tips for the CS Freshmen
Ahmet Bulut
 
Agile Data Science
Ahmet Bulut
 
Data Science
Ahmet Bulut
 
Agile Software Development
Ahmet Bulut
 
Liselerde tanıtım sunumu
Ahmet Bulut
 
Ecosystem for Scholarly Work
Ahmet Bulut
 
I feel dealsy
Ahmet Bulut
 
Bilisim 2010 @ bura
Ahmet Bulut
 
ESX Server from VMware
Ahmet Bulut
 

Recently uploaded (20)

PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
epi editorial commitee meeting presentation
MIPLM
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Difference between write and update in odoo 18
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
infertility, types,causes, impact, and management
Ritu480198
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 

Programming with Python: Week 1

  • 1. Programming with Python Week 1 Dept. of Electrical Engineering and Computer Science Academic Year 2010-2011
  • 2. Why is it called Python?
  • 4. Guido van Rossum • Guido van Rossum, born in 31 January 1956, is a Dutch computer programmer, who invented the Python Programming Language. He is currently employed by Google, where he spends half of his time working on Python development.
  • 5. It is called Python, because • Guido was reading the published scripts from a BBC comedy series Monthy Python from the 1970s. Van Rossum thought he needed a name that was short, unique, and slightly mysterious, so he decided to call the language Python.
  • 6. So what is Python? • Python is an i. interpreted, ii. interactive, iii. object-oriented (OO) iv. programming language (PL). • Python is a dynamically typed language. • Python combines remarkable power with very clear syntax. • Python is portable: it runs on many Unix variants, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, and OS/2.
  • 7. Python Gossip • Python plays well with others. • Python runs everywhere. • Python is friendly, and easy to learn. • Python is open.
  • 8. “Python is ...” • “I love Python! Once you learn and use it, you don't want to go back to anything else. It allows fast development, is easy to test and debug, and comes with an extensive set of powerful features and libraries. For any skeptics out there, YouTube is developed entirely on Python and works beautifully!” said Özgür D. Şahin, Senior Software Engineer at YouTube. • “Python has been important part of Google since the beginning, and remains so as the system grows and evolves. Today, dozens of Google engineers use Python, and we are looking for more people with skills in this language,” said Peter Norvig, Director of Search Quality at Google, Inc. • “Python makes us extremely productive, and makes maintaining a large and rapidly evolving codebase relatively simple,” said Mark Shuttleworth at Thawte Consulting and Canonical Ltd., Ubuntu OS sponsor.
  • 9. Is Python a good language for beginner programmers? • For a student, who has never programmed before, using a statically typed language seems unnatural. It slows the pace. • Python has a consistent syntax and a large standard library. Students can focus on more important programming skills, such as problem decomposition and data type design, code reuse. • Very early in the course, students can be assigned to programming projects that do something.
  • 10. Is Python a good language for beginner programmers? • Python’s interactive interpreter enables students to test language features while they are programming. • They can keep a window with the interpreter running, while they enter their program’s source in another window. • Python is extremely practical to teach basic programming skills to students.
  • 11. The name of our game is learn & practice & dream with Python
  • 12. 1 Installing Python • Open the /Applications folder. • Open the Utilities folder. • Double-click Terminal to open a terminal window and get to a command line. • Type python at the command prompt. • Make sure that you are running Python version 2.6.5.
  • 13. 1.8 Interactive shell • Python leads a double life. • It's an interpreter for scripts that you can run from the command line or by double-clicking the scripts. But • It's also an interactive shell that can evaluate arbitrary statements and expressions. • This is useful for debugging, quick hacking, and testing. • Some people use the Python interactive shell as a calculator!
  • 14. 1.8 Interactive shell • >>> 1+1 • >>> print ‘look mom, I am programming’ • >>> x=3 • >>> y=7 • >>> x+y
  • 15. 1.8 Interactive shell • The Python interactive shell can evaluate arbitrary Python expressions, including any basic arithmetic expression (e.g., 1+1). • The interactive shell can execute arbitrary Python statements (e.g., print). • You can also assign values to variables, and the values will be remembered as long as the shell is open (but not any longer than that.)
  • 16. 2 First Python program odbchelper.py
  • 17. Run the program • On UNIX-compatible systems (including Mac OS X), you can run a Python program from the command line: python odbchelper.py
  • 18. Output of the program
  • 19. 2.2 Declaring Functions • Python has functions like most other languages, but it does not have separate header files like C++ or interface/implementation section like Pascal. Function def buildConnectionString(params): declaration • Note that the keyword def starts the function declaration, followed by the function name, followed by the arguments in parentheses. Multiple arguments (not shown here) are separated with commas.
  • 20. Python Functions • Python functions do not specify the datatype of their return value; they don't even specify whether or not they return a value. • Every Python function returns a value; if the function ever executes a return statement, it will return that value, otherwise it will return None, (Python null value). • The argument, params, doesn't specify a datatype. In Python, variables are never explicitly typed. Python figures out what type a variable is and keeps track of it internally.
  • 21. Python --“dynamically typed” • In Python, you never explicitly specify the datatype of anything. • Based on what value you assign, Python keeps track of the datatype internally.
  • 22. How Python datatypes compare to other PLs • statically typed language: types are fixed at compile time. You are required to declare all variables with their datatypes before using them. Java and C are statically typed languages. • dynamically typed language: types are discovered at execution time; the opposite of statically typed. VBScript and Python are dynamically typed, because they figure out what type a variable is when you first assign it a value. • strongly typed language: types are always enforced. Java and Python are strongly typed. If you have an integer, you can't treat it like a string without explicitly converting it. • weakly typed language: types may be ignored; In VBScript, you can concatenate the string '12' and the integer 3 to get the string '123', then treat that as the integer 123, all without any explicit conversion.
  • 23. Dynamic and Strong • So Python is both dynamically typed, because it doesn't use explicit datatype declarations, and it is strongly typed, because once a variable has a datatype, it actually matters.
  • 24. 2.3 Documenting functions doc • You can document a Python function by giving it a doc string. string • Triple quotes “1 ”2 ”3 signify a multiline string. Everything between the start and end quotes is part of a single string, including carriage returns and other quote characters. • Everything between the triple quotes is the functions’s doc string, which documents what the function does. • You should always define a doc string for your function.
  • 25. 2.4 Everything is an object • Python functions have attributes and they are available at run time. A doc string is an attribute that is available at run time. • A function is also an object.
  • 26. Importing modules • Import search path: when you try to import a module (a chunk of code that does something), Python uses the search path. Specifically, it searches in all directories defined in sys.path. This is a list and it is modifiable with standard list methods. • >>> import sys (hint: sys is a module itself) • >>> sys.path
  • 27. Importing modules • >>> sys.path.append(‘~/Dropbox/EECS Lisans/ Programming with Python/Week 1/Code’) • >>> import odbchelper • >>> print odbchelper.__doc__
  • 28. 2.4 Everything is an object two underscores • Everything in Python is an object, and almost everything has attributes and methods. • All functions have a built-in __doc__, which returns the doc string defined in the function’s source code. • Everything is an object in the sense that it can be assigned to a variable or passed as an argument to a function. • Strings are objects, Lists are objects, Functions are objects, Modules are objects, You are an object.
  • 29. 2.5 Indenting code • Python functions have i. NO explicit begin or end, and ii. NO curly braces to mark where the function code starts and stops. The only delimiter is a colon (:) and the indentation of the code itself.
  • 30. 2.5 Indenting code • Code blocks are defined by their indentation. • By “code block”, I mean functions, if statements, for loops, while loops, and so forth. • Indenting starts a code block. Un-indenting ends that code block. • There are NO explicit braces, brackets, keywords used for marking a code block.
  • 32. code blocks one argument
  • 33. code blocks print statements can take any data type, including strings, integers, and other native datatypes. you can print several things on one line by using a comma-separated list of values
  • 34. code blocks code block code block
  • 36. code blocks • just indent and get on with your life. • indentation is a language requirement. not a matter of style. • Python uses carriage return to separate statements. • Python uses a colon and indentation to separate code blocks. : ...
  • 37. Back to your first program code block
  • 38. Back to your first program code block
  • 39. 8hrs of sleep will make you happier.

Editor's Notes