• Complain

it-ebooks - Python 3 Basics Tutorial

Here you can read online it-ebooks - Python 3 Basics Tutorial full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: iBooker it-ebooks, 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.

it-ebooks Python 3 Basics Tutorial
  • Book:
    Python 3 Basics Tutorial
  • Author:
  • Publisher:
    iBooker it-ebooks
  • Genre:
  • Year:
    2018
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Python 3 Basics Tutorial: summary, description and annotation

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

it-ebooks: author's other books


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

Python 3 Basics Tutorial — 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 3 Basics Tutorial" 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
Table of Contents
  1. 1.1
  2. 1.2
  3. 1.3
    1. 1.3.1
    2. 1.3.2
    3. 1.3.3
  4. 1.4
    1. 1.4.1
    2. 1.4.2
    3. 1.4.3
  5. 1.5
  6. 1.6
    1. 1.6.1
    2. 1.6.2
    3. 1.6.3
  7. 1.7
    1. 1.7.1
    2. 1.7.2
    3. 1.7.3
    4. 1.7.4
  8. 1.8
    1. 1.8.1
    2. 1.8.2
    3. 1.8.3
  9. [Other topics] 1.9
    1. 1.9.1
    2. 1.9.2
    3. 1.9.3
    4. 1.9.4
    5. 1.9.5
    6. 1.9.6
    7. 1.9.7
    8. 1.9.8
    9. 1.9.9
    10. 1.9.10
  10. 1.10
  11. 1.11
  12. 1.12
  13. 1.13
Acknowledgements
Authors

2013 Kristian Rother (krother@academis.eu)

This document contains contributions by Allegra Via, Kaja Milanowska and Anna Philips.

License

Distributed under the conditions of a Creative Commons Attribution Share-alike License 3.0.

Acknowledgements

I would like to thank the following people for inspiring exchange on training and Python that this tutorial has benefited from: Pedro Fernandes, Tomasz Puton, Edward Jenkins, Bernard Szlachta, Robert Lehmann and Magdalena Rother

Background information on Python 3
Background information on Python 3
What is Python?
  • Python is an interpreted language.
  • Python uses dynamic typing.
  • Python 3 is not compatible to Python 2.x
  • The Python interpreter generates intermediate code (in the pycache directory).
Strengths
  • Quick to write, no compilation
  • Fully object-oriented
  • Many reliable libraries
  • All-round language
  • 100% free software
Weaknesses
  • Writing very fast programs is not straightforward
  • No strict encapsulation
What has changed from Python 2 to Python 3?
  • print is now a function
  • all Strings are stored in Unicode (better handling of umlauts and special characters in all languages)
  • many functions like zip(), map() and filter() return iterators
  • the standard library has been cleaned up completely
Shortcuts
Shortcuts
Exercise 1

Simplify the following code using the function sum():

counts = [356, 412, 127, 8, 32]total = 0for number in data: total = total + numberprint(total)
Exercise 2

Simplify the following code using the function range():

i = 0while i < 10: print(i * '*') i += 1
Exercise 3

Simplify the following code using the function zip():

names = ['Lilly', 'Lily', 'Leila', 'Lilja', 'Lillie']counts = [356, 412, 127, 8, 32]table = []i = 0while i < len(names): row = (names[i], counts[i]) table.append(row) i += 1print(table)
Exercise 4

Simplify the following code using the function enumerate():

names = ['Lilly', 'Lily', 'Leila', 'Lilja', 'Lillie']i = 0for name in names: print(i, name) i += 1
Exercise 5

Use list(range()) to create the following lists:

  • [4, 7, 9, 12]
  • [10, 20, 30, 40, 50]
  • [33, 32, 31, 30]
Exercise 6

On which data types does the len() function work?

  • lists
  • dictionaries
  • strings
  • floats
  • sets
Overview of data types in Python
Overview of Data types in Python
Data types

Match the data samples with their types.

Definitions Immutable and mutable data types In Python there are basic and - photo 1

Definitions
Immutable and mutable data types

In Python there are basic and composite data types. The values of basic data types cannot be changed, they are immutable. Most of the composite data types are mutable.

The immutable data types in Python are:

  • Boolean (True / False)
  • Integer (0, 1, -3)
  • Float (1.0, -0.3, 1.2345)
  • Strings ('apple', "banana") - both single and double quotes are valid
  • None (aka an empty variable)
  • Tuples (multiple values in parentheses, e.g. ('Jack', 'Smith', 1990))

The mutable data types are

  • List [1, 2, 2, 3]
  • Dictionary {'name': 'John Smith', 'year': 1990}
  • Set ()
Type conversions

Values can be converted into each other using conversion functions. Try the following:

int('5.5')float(5)str(5.5)list("ABC")tuple([1,2,3])dict([('A',1),('B',2)])set([1,2,2,3])
Dictionaries
Dictionaries
Exercise 1

Find out what each of the expressions does to the dictionary in the center.

Exercise 2 What do the following commands produce d 1A B1 - photo 2

Exercise 2

What do the following commands produce?

d = {1:'A', 'B':1, 'A':True}print(d['A'])
  • False
  • "B"
  • True
  • 1
Exercise 3

What do these commands produce?

d = {1:'A', 'B':1, 'A':True}print(d.has_key('B'))
  • 1
  • True
  • "B"
  • False
Exercise 4

What do these commands produce?

d = {1:'A', 'B':1, 'A':True}print(d.values())
  • True
  • ['A', 1, True]
  • 3
  • [1, 'B', 'A']
Exercise 5

What do these commands produce?

d = {1:'A', 'B':1, 'A':True}print(d.keys())
  • [1, 'B', 'A']
  • ['A', 'B', 1]
  • [1, 'A', 'B']
  • The order may vary
Exercise 6

What do these commands produce?

d = {1:'A', 'B':1, 'A':True}print(d['C'])
  • None
  • 'C'
  • an Error
  • False
Exercise 7

What do these commands produce?

d = {1:'A', 'B':1, 'A':True}d.setdefault('C', 3)print(d['C'])
  • 3
  • 'C'
  • None
  • an Error
First steps in the IPython Shell
First steps on the IPython Shell

There are two ways to use Python: The interactive mode or IPython shell and writing programs. We will use the interactive mode to store data on U.S. baby names.

In the first part of the tutorial, you will use the IPython shell to write simple commands.

Goals

The commands on the IPython shell cover:

  • How to store a number?
  • How to add two numbers together?
  • How to store text?
  • How to convert a number to text and back?
Repeating instructions
Repeating instructions

In our early programs, each Python instruction was executed only once. That makes programming a bit pointless, because our programs are limited by our typing speed.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Python 3 Basics Tutorial»

Look at similar books to Python 3 Basics Tutorial. 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 3 Basics Tutorial»

Discussion, reviews of the book Python 3 Basics Tutorial 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.