Sie sind auf Seite 1von 59

Specialized Programming Languages

Marcin Kamiski
Faculty of Electrical Engineering, Automatic Control and Computer Science

part 1
Presentation co-nanced by the European Union within European Social Fund

Python Programming Language


Example 1

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week.

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49.

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win!

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win! In 2007 69 wins more than 1 000 000 zlotys.

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win! In 2007 69 wins more than 1 000 000 zlotys. One bet costs 2 zlotys.

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win! In 2007 69 wins more than 1 000 000 zlotys. One bet costs 2 zlotys. The winnings represent 51% of the total amount of rates paid for taking part in the game.

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win! In 2007 69 wins more than 1 000 000 zlotys. One bet costs 2 zlotys. The winnings represent 51% of the total amount of rates paid for taking part in the game. The rst drawing: January 27th 1957 more than 50 years ago...

Facts:

Python Programming Language


Example 1

Topic:

Analysis of the results of the popular lottery in Poland (LOTTO)


The drawing three times a week. You must select 6 numbers in range from 1 to 49. If You guessed 3, 4, 5 or 6 numbers You win! In 2007 69 wins more than 1 000 000 zlotys. One bet costs 2 zlotys. The winnings represent 51% of the total amount of rates paid for taking part in the game. The rst drawing: January 27th 1957 more than 50 years ago... The last drawing: November 4th 2008 drawing No. 4609.

Facts:

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

1 bet = 2 zlotys

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org). Command Prompt (StartAll ProgrammsAccessoriesCommand Prompt).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org). Command Prompt (StartAll ProgrammsAccessoriesCommand Prompt). Archive of the lucky numbers from the years 1957-2007 (text le, 150kB).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org). Command Prompt (StartAll ProgrammsAccessoriesCommand Prompt). Archive of the lucky numbers from the years 1957-2007 (text le, 150kB).

More advanced teaching aids:

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org). Command Prompt (StartAll ProgrammsAccessoriesCommand Prompt). Archive of the lucky numbers from the years 1957-2007 (text le, 150kB).

More advanced teaching aids:


wxPython a free GUI toolkit for the Python programming language (http://wxpython.org).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Teaching aids:
Python Programming Language (http://python.org). ConTEXT small, fast and powerful freeware text editor (http://www.contexteditor.org). Command Prompt (StartAll ProgrammsAccessoriesCommand Prompt). Archive of the lucky numbers from the years 1957-2007 (text le, 150kB).

More advanced teaching aids:


wxPython a free GUI toolkit for the Python programming language (http://wxpython.org).
A L TEX a document preparation system (http://www.latex-project.org).

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

No. 4408 4407 4406 4405 4404 ... 5 4 3 2 1

Date 2007-07-04 2007-06-30 2007-06-27 2007-06-23 2007-06-20 ... 1957-02-24 1957-02-17 1957-02-10 1957-02-03 1957-01-27

L1 33 2 13 48 1 ... 49 45 49 27 45

L2 16 37 24 9 12 ... 39 40 45 25 43

L3 4 48 19 24 47 ... 35 37 26 22 39

L4 45 5 42 11 19 ... 15 14 20 11 31

L5 40 41 2 32 18 ... 10 11 19 10 12

L6 47 42 39 2 20 ... 8 2 18 5 8

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers. The question is as follows: did these numbers occurred in results of draws saved in the archive?

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers. The question is as follows: did these numbers occurred in results of draws saved in the archive? Remember: at least three users numbers should match the numbers stored in archive for each draw.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers. The question is as follows: did these numbers occurred in results of draws saved in the archive? Remember: at least three users numbers should match the numbers stored in archive for each draw.

Step 1:
Please prepare program in Python programming language which enables to enter a sequence of six numbers from the keyboard.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 1
for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) print value

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 1
for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) print value

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 2
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) print vector

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 2
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) print vector

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 3
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) print vector print vector[ 0 ] print vector[ 0 ], vector[ 1 ], \ vector[ 2 ], vector[ 3 ], \ vector[ 4 ], vector[ 5 ] print vector[ -1 ], vector[ -2 ], \ vector[ -3 ], vector[ -4 ], \ vector[ -5 ], vector[ -6 ] print vector[ 2 ], vector[ 4 ], print vector[ 1 ], vector[ 3 ], print vector[ 0 ], vector[ 5 ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 3
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) print vector print vector[ 0 ] print vector[ 0 ], vector[ 1 ], \ vector[ 2 ], vector[ 3 ], \ vector[ 4 ], vector[ 5 ] print vector[ -1 ], vector[ -2 ], \ vector[ -3 ], vector[ -4 ], \ vector[ -5 ], vector[ -6 ] print vector[ 2 ], vector[ 4 ], print vector[ 1 ], vector[ 3 ], print vector[ 0 ], vector[ 5 ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) for number in range ( 6 ) : print vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) for number in range ( 6 ) : print vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4a
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print howMany for number in range ( howMany ) : print vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4a
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print howMany for number in range ( howMany ) : print vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4b
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print vector has , howMany, "elements" for number in range ( howMany ) : print vector[, number, "] = ", \ vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4b
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print vector has , howMany, "elements" for number in range ( howMany ) : print vector[, number, "] = ", \ vector[ number ]

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4c
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4c
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4d
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 1, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4d
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 1, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4e
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 3, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4e
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 3, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4f
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 0, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4f
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 0, howMany ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4g
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 2, howMany - 2 ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 4g
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) howMany = len( vector ) print %s %1d %s % ( vector has, howMany, "elements" ) for number in range ( 2, howMany - 2 ) : print %s[ %1d ] = %2d % ( vector, number, vector[ number ] )

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 5
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) for element in vector : print element

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 5
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the value... ) ) vector.append( value ) for element in vector : print element

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers.

Step 1:
Please prepare program in Python programming language which enables to enter a sequence of six numbers from the keyboard.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers.

Step 1:
Please prepare program in Python programming language which enables to enter a sequence of six numbers from the keyboard.

Step 2:
Please prepare program in Python which enables to enter a sequence of six unique numbers from the keyboard.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 6
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( value in vector ) : print .... This number has already been given .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) vector.append( value ) print vector

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 6
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( value in vector ) : print .... This number has already been given .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) vector.append( value ) print vector

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers.

Step 1:
Please prepare program in Python programming language which enables to enter a sequence of six numbers from the keyboard.

Step 2:
Please prepare program in Python which enables to enter a sequence of six unique numbers from the keyboard.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Task 1:
The user should select six numbers.

Step 1:
Please prepare program in Python programming language which enables to enter a sequence of six numbers from the keyboard.

Step 2:
Please prepare program in Python which enables to enter a sequence of six unique numbers from the keyboard.

Step 3:
Please prepare program in Python which enables to enter from the keyboard a sequence of six unique numbers of range from 1 to 49.

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 7
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( not ( ( value > 0 ) and ( value < 50 ) ) or ( value in vector ) ) : while not ( ( value > 0 ) and ( value < 50 ) ) : print .... Give the number of range from 1 to 49 .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( value in vector ) : print .... This number has already been given .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) vector.append( value ) print vector

Python Programming Language


Example 1 Analysis of the results of the popular lottery in Poland

Listing 7
vector = [ ] for number in range ( 6 ) : value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( not ( ( value > 0 ) and ( value < 50 ) ) or ( value in vector ) ) : while not ( ( value > 0 ) and ( value < 50 ) ) : print .... Give the number of range from 1 to 49 .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) while ( value in vector ) : print .... This number has already been given .... value = int( raw_input( Enter the + str ( number + 1 ) + value... ) ) vector.append( value ) print vector

Das könnte Ihnen auch gefallen