2.1.3.8 Lab - Create A Simple Game With Python IDLE
2.1.3.8 Lab - Create A Simple Game With Python IDLE
Objectives
Part 1: Launch VirtualBox and Enter the I2IoT server VM
Part 2: Create a Simple Game with Python IDLE
Part 3: IDLE for Python
Background
Python, a programming language, allows for simpler statements. Python is very easy to use, powerful, and
versatile. It has become the language of choice for many IoT developers. One of the main reasons for the
popularity of Python is the developer community; Python developers have created and made available many
specific modules that can be imported into any program to immediately lend added functionality.
Scenario
In this lab, you will create a simple game using Python IDLE.
Required Resources
A modern personal computer with sufficient RAM and with internet access.
VirtualBox with I2IoT server installed.
© 2018 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 1 of 5
Lab – Create a Simple Game with Python IDLE
b. Click I2IoT – GUI on the left pane to launch the server VM.
c. The default username is IoT_user with no password. Click the blue bar IoT_user in the middle of the
screen to log in to the VM.
© 2018 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 2 of 5
Lab – Create a Simple Game with Python IDLE
c. Use the ls command to show the list of contents in the current directory. Use the ls command with the -l
option to show detailed information about the contents.
d. Use the cd Documents command to change the directory to the /home/IoT_user/Documents directory.
Verify by using the command pwd.
© 2018 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 3 of 5
Lab – Create a Simple Game with Python IDLE
b. Click File -> New File to open a new (Untitled) Python script.
c. Type the codes in the script, and note that the codes are color coded with open and close parentheses
matched.
© 2018 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 4 of 5
Lab – Create a Simple Game with Python IDLE
d. Click File -> Save, and save the current script as 2.py in the current directory. Click the Save button.
e. Click Run -> Run Module (or press F5). The shell window will display the result.
Reflection
How to catch if the player enters a number beyond the range of 0 to 1024?
_____________________________________________________________________________________
_____________________________________________________________________________________
How to catch if the player enters a float number?
_____________________________________________________________________________________
_____________________________________________________________________________________
© 2018 Cisco and/or its affiliates. All rights reserved. This document is Cisco Public. Page 5 of 5