• Complain

Kurniawan A. - Python Programming by Example

Here you can read online Kurniawan A. - Python Programming by Example full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Python Programming by Example
  • Author:
  • Genre:
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Python Programming by Example: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Python Programming by Example" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

PE Press, 2015. 148 p. + Examples.
This book helps you to learn how to program in Python. Several code and scenario samples are provided to accelerate your learning. All scripting samples are written in Python
3.x.The following is highlight topic in this book:
Development Environment;
Python Programming Language;
Lists, Tuples and Dictionary;
Functions;
Python Object Oriented;
Python Modules and Packages;
String operations;
File Operations;
Error Handling;
Building Own Python Module;
Concurrency;
Encoding;
Hashing and Cryptography;
Database Programming;
Socket Programming;
Python Regular Expressions;
Python GUI Programming;
Python Unit Testing. iPAD Amazon Kindle, PC , Cool Reader (EPUB), Calibre (EPUB, MOBI, AZW3), Adobe Digital Editions (EPUB), FBReader (EPUB, MOBI, AZW3).

Kurniawan A.: author's other books


Who wrote Python Programming by Example? Find out the surname, the name of the author of the book and a list of all author's works by series.

Python Programming by Example — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Python Programming by Example" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Copyright

Python Programming by Example

Agus Kurniawan

1st Edition, 2015

Copyright 2015 Agus Kurniawan

* Cover photo is credit to Fajar Ramadhany, Bataviasoft, http://bataviasoft.com/.

Table of Contents
Preface

This book is a brief reference to the Python programming language. It describes all the elements of the language and illustrates their use with code examples.

Agus Kurniawan

Depok, November 2015

1. Development Environment
1.1 Installation

Python is a widely used general-purpose, high-level programming language. Installation of Python application is easy. For Windows, Linux and Mac Platform, you download setup file from Python website, https://www.python.org/downloads/. Download and run it. Follow installation commands.

If you're working on Windows platform, you can run setup file and follow instruction.

12 Development Tools Basically you can use any text editor to write Python - photo 1

1.2 Development Tools

Basically, you can use any text editor to write Python code. The following is a list of text editor:

  • vim
  • nano
  • PyCharm, https://www.jetbrains.com/pycharm/
  • Intellij IDEA, https://www.jetbrains.com/idea/
  • Sublime text, http://www.sublimetext.com/
  • Visual Studio, https://www.visualstudio.com

In this book, I use PyCharm for development tool. Jetbrains provides community and Education licenses for PyCharm.

13 Python Shell After installed Python you obtain Python shell on your - photo 2

1.3 Python Shell

After installed Python, you obtain Python shell on your platform. You can type this command on Terminal or Command Prompt for Windows Platform.

python

This is Python 2.x. Then, you get Python shell, shown in Figure below.

If you installed Python 3x you can Python shell by typing this command - photo 3

If you installed Python 3.x, you can Python shell by typing this command.

python3

This is Python 3.x. Then, you get Python shell, shown in Figure below.

Output program on Windows platform After you call Python shell you - photo 4

Output program on Windows platform.

After you call Python shell you obtain the shell It shows gtgtgt on - photo 5

After you call Python shell, you obtain the shell. It shows >>> on Terminal.

Try to do the following command.

>>> a = 3>>> b = 5>>> print a>>> c = a * b>>> print c

In Python 3.x, print a is replaced by print(a).

The following is a sample output of program.

A sample output for Windows platform 14 Running Python Application from - photo 6

A sample output for Windows platform 14 Running Python Application from - photo 7

A sample output for Windows platform.

14 Running Python Application from Files You can run your program by writing - photo 8

1.4 Running Python Application from Files

You can run your program by writing them on a file. For instance, you create a file, called ch01_01.py, and write this script.

print ( 'hello world from python' )

To run the program, you can type this command on Terminal.

python ch01_01.py

If you want to run the program under Python 3.x, type this command on Terminal.

python3 ch01_01.py

Program output:

2 Python Programming Language This chapter explains the basic of Python - photo 9

2. Python Programming Language

This chapter explains the basic of Python programming language.

2.1 Common Rule

Python language doesn't write ";" at the end of syntax like you do it on C/C++ languages. Here is the syntax rule of Python:

syntax_code1syntax_code2syntax_code3
2.2 Variables

In this section, we explore how to define a variable and assign its value. By default, we define variables on Python with assigning value .

# declare variables num = area = 58.7 city = 'Berlin' country = "Germany" z = + j # complex number

If you want to declare variables without assigning values, you can set it using None.

# declare variable without initializing value counter = None index = None

Write these codes for testing.

# declare variables num = area = 58.7 city = 'Berlin' country = "Germany" z = + j # complex number # declare variable without initializing value counter = None index = None global var_globalvar_global = print (num) print (area) print (city) print (country) print (z) print (z . real) print (z . imag) print (var_global)

Save these scripts into a file, called ch02_01.py.

Now you can type this file using Python 3.x.

$ python3 ch02_01.py

A sample of program output can seen in Figure below.

23 Comment You may explain how to work on your code with writing comments To - photo 10

2.3 Comment

You may explain how to work on your code with writing comments. To do it, you can use # and """ syntax. Here is sample code:

# this a comment """ These are long comments These are long comments These are long comments """
2.4 Arithmetic Operations

Python supports the same four basic arithmetic operations such as addition, subtraction, multiplication, and division. For testing, create a file, called ch02_02.py.

The following is the code illustration for basic arithmetic in ch02_02.py:

a = 2.3 b = c = a + b print (c)c = a - b print (c)c = a * b print (c)c = a / b print (c)

Save and run this program.

python3 ch02_02.py

A sample of program output:

25 Mathematical Functions Python provides math library If youre working with - photo 11

2.5 Mathematical Functions

Python provides math library. If youre working with Python 2.x, you can read this library on https://docs.python.org/2/library/math.html . For Python 3.x, you can read math library on https://docs.python.org/3/library/math.html .

Create a file, called ch02_03.py. Write the following code.

from math import * a = 1.8 b = 2.5 c = pow (a, b) print (c)c = sqrt(b) print (c)c = sin(a) print (c) print (pi)

Save and run the program.

python3 ch02_03.py

A sample of program output:

26 Increment and Decrement Python doesnt has special syntax for increment and - photo 12

2.6 Increment and Decrement

Python doesn't has special syntax for increment and decrement. We can define increment and decrement as follows.

  • ++ syntax for increment. a++ can be defined as a = a + 1
  • -- syntax for decrement. a-- can be defined as a = a - 1

For testing, create a file, called

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Python Programming by Example»

Look at similar books to Python Programming by Example. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Python Programming by Example»

Discussion, reviews of the book Python Programming by Example and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.