BDM’s Coding Tips, Tricks & Fixes - 2018 UK.pdf

(11707 KB) Pobierz
New!
¦
Coding
Tips, Tricks & Fixes
BDM s
Python 3
¦
¦
Linux
Scripting
¦
C
++
Coding
The ultimate guide to advancing
your coding skills and knowledge
Avoid mistakes
and become a
better coder
Learn
how to start
programming
Featuring C++ and
Linux Scripting
100% INDEPENDENT
Packed with
top tips, tricks
and tutorials
867
Expert Hi
Inside
Over
nts
Coding
Tips, Tricks & Fixes
Your guide to better coding
Everything we interact with in our modern digital world has been programmed
by someone. Whether you’re sat in front of your computer, changing channels
on your TV, sending someone a text or even putting the washing machine on,
there’s some form of programming interacting with you.
Programming is everywhere. From clicking an icon on your desktop to open
a web browser to calculating the vast distances between the stars. It’s one of
the most important skills you can have in the modern world and it’s only going
to get bigger as we move into a new generation of interconnected devices
and mediums.
Starting to learn to code isn’t easy but we’re here to help you get going. In the
pages of this book you can learn how to start coding using Python, C++, Linux
scripting and FUZE BASIC with the Raspberry Pi. We cover the common pitfalls
and mistakes every coder falls into and how to avoid them in the future.
There’s a section filled with some great Python coding examples, to showing you
tips and tricks to help make the system do what you want it to; and we look at how
to get help with your code and how to test it in a safe and secure environment.
With programming you never stop learning, so Coding – Tips, Tricks & Fixes is
here to teach you what you need to continue your journey into the wonderful
world of coding.
BDM’s i-Tech Special
BDM’s
BDM’s Coding – Tips, Tricks & Fixes
ISBN 978-1-907306-85-3
Published by:
. . . . . . . . . . . . . . . .Papercut Limited
Managing Editor:.
. . . . . . . . . . . .James Gale
Art Director & Production:
. . .Mark Ayshford
Production Manager:
. . . . . . . .Karl Linstead
Design:
. . . . . . . . . . . . . . . . . . . . . .Robin Drew, Lena Whitaker
Editorial:.
. . . . . . . . . . . . . . . . . . . .David Hayward
Sub Editor:
. . . . . . . . . . . . . . . . . . .Paul Beard
Digital distribution by:
Pocketmags.com, Zinio.com, Apple App Store & Google Play
For all advertising and promotional opportunities contact:
enquiries@bdmpublications.com
Copyright © 2018 Papercut Limited. All rights reserved.
INTERNATIONAL LICENSING
– Papercut Limited has many great publications and
all are available for licensing worldwide.
For more information go to: www.brucesawfordlicensing.com; email: bruce@
brucesawfordlicensing.com; telephone: 0044 7831 567372
Editorial and design are the copyright © Papercut Limited. No part of this publication
may be reproduced in any form, stored in a retrieval system or integrated into any
other publication, database or commercial programs without the express written
permission of the publisher. Under no circumstances should this publication and
its contents be resold, loaned out or used in any form by way of trade without
the publisher’s written permission. While we pride ourselves on the quality of
the information we provide, Papercut Limited reserves the right not to be held
responsible for any mistakes or inaccuracies found within the text of this publication.
Due to the nature of the software industry, the publisher cannot guarantee that all
tutorials will work on every version of Raspbian OS. It remains the purchaser’s sole
responsibility to determine the suitability of this book and its content for whatever
purpose. Images reproduced on the front and back cover are solely for design
purposes and are not representative of content. We advise all potential buyers
to check listing prior to purchase for confirmation of actual content. All editorial
opinion herein is that of the reviewer as an individual and is not representative of the
publisher or any of its affiliates. Therefore the publisher holds no responsibility in
regard to editorial opinion and content.
BDM’s Coding – Tips, Tricks & Fixes
is an independent publication and as such does
not necessarily reflect the views or opinions of the producers contained within. This
publication is not endorsed or associated in any way with The Linux Foundation,
The Raspberry Pi Foundation, ARM Holding, Canonical Ltd, Python, Debian Project,
Linux Mint, Lenovo, Dell, Hewlett-Packard, Apple, Samsung or any associate or
affiliate company. All copyrights, trademarks and registered trademarks for the
respective companies are acknowledged. Relevant graphic imagery reproduced
with courtesy of Lenovo, Hewlett-Packard, Dell, Samsung, FUZE Technologies Ltd,
Linux Mint and Apple.
Additional images contained within this publication are reproduced under licence
from Shutterstock.com.
Prices, international availability, ratings, titles and content are subject to change. All
information was correct at time of print. Some content may have been previously
published in other volumes or titles.
Papercut Limited
Registered in England & Wales No: 4308513
@bdmpubs
BDM Publications
www.bdmpublications.com
Coding – Tips, Tricks & Fixes
Contents
6
8
10
12
14
Coding and Programming
Choosing a Programming Language
Learning to Code – Study Tips
Coding Tools and Resources
Being a Programmer
36
38
40
42
44
46
Equipment You Will Need
Getting to Know C++
How to Set Up C++ in Windows
How to Set Up C++ on a Mac
How to Set Up C++ in Linux
Other C++ IDEs to Install
16
Say Hello to Python
18
20
22
24
26
28
30
Why Python?
Equipment You Will Need
Getting to Know Python
How to Set Up Python in Windows
How to Set Up Python on a Mac
How to Set Up Python in Linux
Installing a Text Editor
48
50
52
54
56
58
60
62
64
66
68
Coding on Linux
Why Linux?
Equipment You Will Need
Transfer Mint to DVD or USB
Installing VirtualBox
Testing Linux Mint’s Live Environment
Installing Linux Mint on a PC
Installing Linux Mint in VirtualBox
Getting Ready to Code in Linux
Creating Bash Scripts – Part 1
Creating Bash Scripts – Part 2
32
34
4
Say Hello to C++
Why C++?
BDM’s Coding - Tips, Tricks & Fixes
Contents
70
72
74
76
78
Creating Bash Scripts – Part 3
Creating Bash Scripts – Part 4
Creating Bash Scripts – Part 5
Command Line Quick Reference
A-Z of Linux Commands
108
110
112
114
116
118
120
122
Coding with FUZE BASIC – Part 1
Coding with FUZE BASIC – Part 2
Coding with FUZE BASIC – Part 3
Using a Breadboard
Using the FUZE IO Board
Using a Robot Arm with FUZE BASIC
FUZE BASIC Examples – Part 1
FUZE BASIC Examples – Part 2
80
Working with Code
82
84
86
88
90
92
94
96
98
Common Coding Mistakes
Beginner Python Mistakes
Beginner C++ Mistakes
Beginner Linux Scripting Mistakes
Code Checklist
Where to Find Help with Code
Test Your Code Online
Python OS Module Error Codes
Python Errors
124
Code Project Examples
126
128
130
131
132
134
136
138
140
142
144
Python File Manager
Number Guessing Game
Polygon Circles
Random Number Generator
Basic GUI File Browser
Vertically Scrolling Text
Text Adventure Script
Python Digital Clock
Hangman Game Script
Where Next?
Common Coding Terms
100
Programming with the FUZE
102
104
106
Introducing the FUZE Project
Setting Up the FUZE
Getting Started with FUZE BASIC
www.bdmpublications.com
BDM’s Coding - Tips, Tricks & Fixes
5
Zgłoś jeśli naruszono regulamin