您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Make-your-own-Python-Text-Adventure.pdf.pdf
  所属分类: 其它
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2019-09-14
  提 供 者: weixin_********
 详细说明:Make-your-own-Python-Text-Adventure.pdfContents Chapter 1: Getting Started m mmammammmmnn. ntroducti0n…1 Who this book is for How To use this book Setting Up Your Workspace..... menemen Python Versions 4 Installing Python Verify Your Installation .mam Chapter 2: Your First Program ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Creating a Module .nmenemnmnnnnnemennennnn 10 Writing Code…,..,.10 Running Python Programs Homework,……12 Chapter 3: Listening to Your Users ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 13 Your friends: stdout and stdin Reading from Standard Input 15 Saving information 15 Data Types…,,,. Homework 18 TABLE OF CONTENTS Chapter 4: Decisions nmmmmamImaI 19 Booleans If-statements 2 Boolean operations……24 Homework,……26 Chapter 5: Functions g27 Data n data out Homework 32 Chapter 6: Lists. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■■ 33 What is a list?…33 Common List Operations…… 35 Add 35 Length 35 Get 36 Search.……136 Adding Lists to the Game 38 Homework Chapter 7: Loops 41 Whille Loops F0r- Each Loops… 43 L00 o Counters,,,.,.,.,.,.,.,.,.,.,,, Ranges.,...,....,,,45 Using Enumerate Nesting…,,,,,,,,,, The Game Loop…… Homework…152 TABLE OF CONTENTS Chapter8:0 bjects,,,,,,,…,,,,,,,…,,m53 Object Members 53 Defining Objects with Classes Using_ inito to Initialize objects Using__str 0 to Print Objects.mmmamammammmmammammmmmmnmn 57 Adding Weapons to the Game mmmemennmemmmnnaamemnn.mn. 6( A Dash of object-Oriented Programming . Homework 64 Chapter 9: Exceptions.an 65 Validating User Input 65 Checking object Members. Raising Exceptions Intentionally. Homework 70 Chapter 10: Intermezzo an ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Organizing Code Into Multiple Files Importing from other Files.mmmnamamaanmemnnnmnnnmmn. 75 Homework 76 Chapter11: Building Your World,,…,…,,,,…,;77 TheX- Y Grid…, Moving in the World 81 Chapter 12: Making the World More Interesting ammmammammaI aa 85 Enemies….85 Do You have any potions.OrF000?.……93 TABLE OF CONTENTS Chapter 13: World-Building Part 2rmnr ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■口■■■■■口■■■ 99 Dictionaries Creating a Dictionary. Get 100 Add/Update....101 Delete 102 L00p.……102 Limiting Actions 103 Expanding the World.......n Chapter 14: Econ 101 mmmmammmmmmmmammm 115 Share the wealth ,115 Giving the Trader a Home 118 Expanding the World 122 Chapter 15: Endgame ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 127 Finishing Up What next?.mm. 129 Add more features to the game Make Your Job Easier with Python Scripts...........130 Write a Web application mnmnnmenamnaeaanaeenanennn 130 ppendix A: Homework Solutions n ■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■ 131 Chapter2: Your First program…….,,,,,,,,…131 Chapter 3: Listening to Your Users 132 Chapter 4: Decisions.m...............m.133 Chapter 5: Functions 134 Chapter6:Lits…. 135 TABLE OF CONTENTS Chapter7:L0ops…........,,137 Chapter 8: objects 139 Chapter9: Exceptions…… 143 Appendix B: Common Errors.mam mmamamammmn 145 Attribute error 145 Name error 145 TypeError…,,,,,,,,,,,146 Index 147 CHAPTER 1 Getting Started Introduction So you' ve heard the Internet chanting Learn to code! Learn to code and you ve read that python is a good place to start.. but now what? many people who want to program dont know where to start. The idea that you can create"anything"with code is paralyzing This book provides a clear goal: learn Python by creating a text adventure This book will teach you the fundamentals of programming, including how to organize code and some coding best practices. By the end of the book, you will have a working game that you can play or show off to friends. You will also be able to change the game and make it your own by writing a different story line, including adding new items, creating new characters, etc. Learning to program is an exciting endeavor, but can feel daunting at first. However, if you stick with it, you could become a professional programmer or a weekend hobbyist, or both! My story is similar to the stories of many programmers: The first thing I programmed was a number guessing game in QBASIC and now programming is my job. I hope that you, too, can join us, and i thank you for choosing this book as the place to start o Phillip Johnson 2018 P. Johnson, Make Your Own Python Text Adventure htos:// doi. org/10.1007/978-1-4842-3231-6_1 CHAPTER 1 GETTING STARTED Who this book is for This book is intended for people who have never programmed before or for novice programmers starting out with Python. If you're in this second group, you can probably skim some of the early material Although this is geared toward beginners, I do make some assumptions that you know computer basics such as opening a command prompt, installing software, etc. If you get stuck on anything an Internet search for "how to do [ thing] on [operating system]"will typically help you out. Particularly useful web sites for programmers are StackOverflow (http://stackoverflow.comandSuperuser(http://superuser.com),2 so if you see them in your search results, give them a shot first How To Use this book In each chapter of the book, you will make progress on the overall goal of creating your text adventure The early chapters may seem like slow going because they focus on learning the basics of Python. Things will pick up in the second half of the book, when the focus shifts toward building the game world I suggest reading this book on or beside your computer so you can easily go back and forth between reading and writing code. Each of the chapters in the first half of the book will end with a homework section These problems won't be required for the main game, but you should at least try them When applicable, solutions are provided at the end of the book Most of the python code in this book will look like this greeting ="Hello, World print (greeting) Thttp://stackoverflow.com http://superuser.com CHAPTER 1 GETTING STARTED Code that is intended to be entered into an interactive python session (see Chapter 3) will look like this >>> greeting ="Hello, World! >>>print(greeting) References to code or commands that appear inline will appear like this. Technical terms that you should learn appear like this If you ever get stuck, you can download the code for each chapter in the book here. Resist the urge to copy and paste everything! Youll retain more information if you type out the code. However, we all make mistakes, so if you cant figure out what's wrong, you can compare your code against mine. If you re really sure everything is the same, double-check with an online comparison tool like DiffChecker or Mergely You can also check Appendix b for some common errors you may run into Finally, this game is your game. It is fully customizable, and if you feel comfortable adding more rooms and enemies, changing the story, making it more difficult, etc. please do so. I will point out good customization opportunities like this Customization Point Some notes about customization Keep in mind that each chapter builds on the last, so if you deviate too far from the material, you may want to save your customized code in another directory so you can keep learning from the source material shttps://www.dropboxcom/sh/udvdkxtjhtlgdh1/aad9hod6vtb5rgfz7k Bv-ghua?dl=o Ahttps://www.difFchecker.com 5http://www.mergeLy com/editor
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: