没有合适的资源?快使用搜索试试~ 我知道了~
首页full speed python
full speed python
需积分: 10 70 浏览量
更新于2023-05-26
评论
收藏 1008KB PDF 举报
提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率提高 python 开发效率
资源详情
资源评论
资源推荐

Getting up to speed with Python
João Ventura
v0.2

Contents
1 Introduction 2
2 Installation 3
2.1 Installing on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Installing on macOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Basic datatypes 7
3.1 Exercises with numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Exercises with strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Exercises with lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4 Modules and functions 10
4.1 Exercises with the math module . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Exercises with functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3 Recursive functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.4 Exercises with recursive functions . . . . . . . . . . . . . . . . . . . . . . 12
5 Iteration and loops 13
5.1 Exercises with the for loop . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 Exercises with the while statement . . . . . . . . . . . . . . . . . . . . . 15
6 Dictionaries 16
6.1 Exercises with dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 Exercises with sub-dictionaries . . . . . . . . . . . . . . . . . . . . . . . . 18
7 Classes 19
7.1 Exercises with classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.2 Class inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7.3 Exercises with inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1

Chapter 1
Introduction
This book aims to teach the basics of the Python programming language using a practical
approach. Its method is quite basic though: after a very simple introduction to each topic,
the reader is invited to learn by solving the proposed exercises.
These exercises have been used extensively in my web development and distributed com-
puting classes at the Superior School of Technology of Setúbal. With these exercises,
most students are up to speed with Python in less than a month. In fact, students of
the distributed computing course, taught in the second year of the software engineering
degree, become familiar with Python’s syntax in two weeks and are able to implement a
distributed client-server application with sockets in the third week.
This book is divided in the following chapters: in chapter 2 I will provide the basic
installation instructions and execution of the Python interpreter. In chapter 3 we will
talk about the most basic data types, numbers and strings. In chapter 4 we will start
tinkering with functions, and in chapter 5 the topic is about "loops". In chapter 6 we
will work with dictionaries and finally, in chapter 7 we will finish the book with some
exercises about classes and object oriented programming.
Please note that this book is a work in progress and as such may contain quite a few
spelling errors that may be corrected in the future. However it is made available as it is
so it can be useful to anyone who wants to use it. I sincerely hope you can get something
good through it.
This book is made available in github (check it at https://github.com/joaoventura/
full-speed-python) so I welcome any pull requests to correct misspellings, to suggest
new exercises or clarification of the current content.
All the best,
João Ventura - Adjunct Professor at the Escola Superior de Tecnologia de Setúbal
2

Chapter 2
Installation
In this chapter we will install and run the Python interpreter in your local computer.
2.1 Installing on Windows
1. Download the latest Python 3 release for Windows on https://www.python.org/
downloads/windows/ and execute the installer. At the time of writing, this is
Python 3.6.4.
2. Make sure that the "Install launcher for all users" and "Add Python to PATH"
settings are selected and choose "Customize installation".
3. In the next screen "Optional Features", you can install everything, but it is essential
to install "pip" and "pylauncher (for all users)". Pip is the Python package manager
that allows you to install several Python packages and libraries.
4. In the Advanced Options, make sure that you select "Add Python to environment
variables". Also, I suggest that you change the install location to something like
C:\Python36\ as it will be easier for you to find the Python installation if something
goes wrong.
3

5. Finally, allow Python to use more than 260 characters on the file system by selecting
"Disable path length limit" and close the installation dialog.
6. Now, open the command line (cmd) and execute "python" or "python3". If every-
thing was correctly installed, you should see the Python REPL. The REPL (from
Read, Evaluate, Print and Loop) is a environment that you can use to program
small snippets of Python code. Execute exit() to exit.
4
剩余21页未读,继续阅读


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0