1. Trang chủ
  2. » Tất cả

313356164-erle-robotics-learning-python-gitbook-free-pdf

129 32 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 129
Dung lượng 1,03 MB

Nội dung

Table of Contents Introduction What is Python? Python in Erle First steps i Introducing comments ii Displaying values on the screen iii Variables i Integer and float variables ii Boolean variables iii String variables iv Asking the user for input v Random numbers iv Identation v Math operators vi Date and time Records vii Exercises: First steps Control flow i Logical operators ii Conditional statements iii Errors and Exceptions iv Exercises: Control flow Functions i Function basics: Defining functions ii Importing functions iii Built-in functions iv Exercises: Functions Lists and Dictionaries i Lists basics i Strings as a list ii For loop with lists iii Function + Lists ii Dictionaries basics i For loop with dictionaries ii Iterators for dictionaries iii Exercises: List and Dictionaries Exercise:Battleship i Battleship ii Solution:Battleship Loops i Loops basics ii While loops iii For loops iv Exercises: Loops 10 Exercise: Exam statistics i Exam statistics ii Solution:Exam statistics 11 Advanced topics in Phyton i List Comprehensions ii List Slicing iii Lambdas iv Exercises:Advances topics in Python 12 Introduction to Bitwise Operators i Bitwise operators basics ii The Base 2 Number System iii Bitwise operators iv Advanced concepts about bitwise operators v Exercises:Introduction to Bitwise Operators 13 Classes i Classes basics ii Member variables and functions iii Inheritance iv Exercises:Classes 14 Exercise: Car i Car ii Solution:Car 15 File Input/Output i Files basics ii Exercises: File Input /Output Erle Robotics Python Gitbook book passing Book This book is a Python Programming Language tutorial using Erle board Erle is a small-size Linux computer for making drones Throught this tutorial you will find examples and explanations of how to use Python's sintaxis, variables, functions and so on Definitely, you will learn to program in Python language About For years we've been working in the robotics field, particularly with drones We have passed through different Universities and research centers and in all these places we actually found that most of the drones are black boxes (check out our 60s pitch) Not meant to be used for learning, research The software they use is in most of the cases unknown, closed source or not documented Given these conditions, how are we going to educate the next generations on this technologies? How do you get started programming drones if you don't have $1000+ budget? Which platform allows me to get started with drones without risking a hand? We are coming up with an answer to all these questions, our technology at Erle Robotics and our drones brain: Erle-brain Inspired by the BeagleBone development board, we have designed a small computer with about 36+ sensors, plenty of I/O and processing power for real-time analysis Erle is the enabling technology for the next generation of aerial and terrestrial robots that will be used in cities solving tasks such as surveillance, enviromental monitoring or even providing aid at catastrophes Our small-size Linux computer is bringing robotics to the people and businesses License Unless specified, this content is licensed under the Creative Commons Attribution-NonComercial-Share Alike 3.0 Unported License To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA All derivative works are to be attributed to Erle Robotics S.L For a list of authors refer to erle_gitbook/graphs/contributors For any questions, concerns, or issues submit them to support [at] erlerobot.com What is Phyton? Python is an interpreted programming language whose philosophy emphasizes a syntax that encourages readable code It is a multi-paradigm programming language, since it supports object-oriented, imperative programming and to a lesser extent, functional programming It is an interpreted language, it uses dynamic typing and is multiplatform You can use it to create web apps, games, even a search engine It is managed by the Python Software Foundation It has an open source license called Python Software Foundation License, 1 which is compatible with the GNU General Public License from version 2.1.1, and incompatible in some earlier versions Python official website Phyton in Erle Open a Erle terminal and try typing: python If Python gets initialized, you are ready Jump to the last paragraph of this page Compiling code If not, follow the steps bellow: Installing and configuring Phyton For installing and running Python in Erle, the first thing you should do is downloading python for Linux from the ofiicial website (it is free): https://www.python.org/download/ Python 3.4.1 compressed source tarball (for Linux, Unix or Mac OS X) Python 3.4.1 xzipped source tarball (for Linux, Unix or Mac OS X, better compression) This two files are avaliable for Linux, so choose one You can donwload it directly in Erle, using the command line: wget http://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz The other option is to download it to your computer and then using scp command copy it to Erle You can find the instructions in this tutorial, more specifically ,in this section After that you need to extract the files, doing for example: tar -xzf Python-3.4.1.tgz You should configure the path and type: /configure make sudo make install sudo apt-get install python For more information, or more detailed explanations, you can read this short tutorial Compiling code After having Python installed, for compilling a code you have two possibilities: Store the code in a python_file.py, and running it by typing: python python_file.py Typing: python And after that type the code.You can use quit() to exit First steps Here you can find the basics of python programming Introducing comments Single Line Comments Comments make your program easier to understand When you look back at your code or others want to collaborate with you, they can read your comments and easily figure out what your code does The # sign is for comments A comment is a line of text that Python won't try to run as code It's just for humans to read Practice 1 Write a comment on line 1 Make sure it starts with # It can say anything you like The result when running a comment on the interpeter must be the following one: root@erlerobot:~# touch Comment.py root@erlerobot:~# echo ' #This is a comment (readonly)' > Comment.py root@erlerobot:~# root@erlerobot:~# root@erlerobot:~# python Comment.py root@erlerobot:~# Multi-Line Comments The # sign will only comment out a single line While you could write a multi-line comment, starting each line with #, that can be a pain Instead, for multi-line comments, you can include the whole block in a set of triple quotation marks: """This is a paragraph containing readonly comments"""

Ngày đăng: 13/04/2019, 01:35