An introduction to a simple, yet powerful programming language - PowerPoint PPT Presentation

About This Presentation
Title:

An introduction to a simple, yet powerful programming language

Description:

An introduction to a simple, yet powerful programming language. Key Features ... Write a word in Italian: Ciao. Your italian word was Ciao. Input # Math. a=10. b=8.2 ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 15
Provided by: and107
Category:

less

Transcript and Presenter's Notes

Title: An introduction to a simple, yet powerful programming language


1
  • An introduction to a simple, yet powerful
    programming language

2
Key Features
  • very clear, readable syntax
  • strong introspection capabilities
  • intuitive object orientation
  • natural expression of procedural code
  • full modularity, supporting hierarchical packages
  • exception-based error handling
  • very high level dynamic data types
  • extensive standard libraries and third party
    modules for virtually every task
  • extensions and modules easily written in C, C
    (or Java for Jython, or .NET languages for
    IronPython)
  • embeddable within applications as a scripting
    interface

3
Examples
  • The following examples shows some key features
  • Input
  • Lists
  • Tuples
  • Flow control
  • While
  • If
  • Dictionaries
  • Exceptions

4
HelloWorld
Hello World print 'Hello World'
/home/user/Python/Pythongt python
HelloWorld.py Hello World /home/user/Python/Python
gt
5
Input
Input word raw_input("Write a word in
italian ")? print "Your italian word was", word
Write a word in Italian Ciao Your italian word
was Ciao
6
Input
Math a10 b8.2 print a/3, a/3.0 print b/2,
b/2.0 print "(ba)/3.0" , (ba)/3.0, "."
3 3.33333333333 4.1 4.1 (ba)/3.0 27.3333333333
.
7
Flow Control
Control i1 while i lt 7 if i 3 print
"3" elif i4 print "4" else print
"x" ii1 print "End"
x x 3 4 x x End

8
Lists
Lists and Tuples cars'volvo', 'saab', 'fiat',
'skoda' print cars2 cars.append('audi')? print
cars
fiat 'volvo', 'saab', 'fiat', 'skoda', 'audi'

9
Tuples
scooters 'vespa', 'lambretta' scooter.append()
does not work on tuples! print scooters,
scooters0
('vespa', 'lambretta') vespa

10
list()?
vehiclelist()? vehicle.append(scooters)? vehicle.
append(cars)? print vehicle print vehicle1
('vespa', 'lambretta'), 'volvo', 'saab',
'fiat', 'skoda', 'audi' 'volvo', 'saab',
'fiat', 'skoda', 'audi'

11
for statement
for car in cars print car
volvo saab fiat skoda audi

12
Dictionaries
Dictionaries and Exceptions EngIta'all''tutto
', 'begin' 'cominciare', 'dark' 'buio',
'scuro', 'find' 'trovare' print
EngIta print EngIta'begin' print
EngIta'dark' print for word in EngIta print
word" ", EngItaword
'dark' 'buio', 'scuro', 'all' 'tutto',
'begin' 'cominciare', 'find' 'trovare' comincia
re 'buio', 'scuro' dark 'buio',
'scuro' all tutto begin cominciare find
trovare
13
Exceptions
try word raw_input("Write a word in English
")? print EngItaword except KeyError print
"Word not in dictionary!"
Write a word in English dark 'buio',
'scuro' Write a word in English light Word not
in dictionary!
14
Conclusions
  • Python is rather easy to learn
  • The syntax is similar to C/C and Java
  • Use indention and not
  • Python also have features that is different from
    C, or even are unique for Python!
  • Lists
  • Tuples
  • Dictionaries
Write a Comment
User Comments (0)
About PowerShow.com