Skip to content

Commit 0edd224

Browse files
committed
testing
1 parent 731852c commit 0edd224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1461
-0
lines changed

python_intro/Readme.md

+419
Large diffs are not rendered by default.

python_intro/images/CalvinHamlet.png

178 KB
Loading
72.1 KB
Loading
34.8 KB
Loading

python_intro/images/HelloWorld.png

1.52 MB
Loading

python_intro/images/Rollercoaster.gif

17.1 KB
Loading
436 KB
Loading
613 KB
Loading
181 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
print "Hello world!"
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
greeting = "Hello"
2+
3+
name = "world"
4+
5+
salutation = greeting + " " + name + "!"
6+
7+
print salutation
8+
9+
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def greet( name ):
2+
print "Hello " + name + "!"
3+
print "Nice to see you."
4+
print "Thank you for coming to CODE@TACC."
5+
6+
greet( "world" )
7+
greet( "friend" )
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def get_name():
2+
result = raw_input( "What is your name? ")
3+
return result
4+
5+
def greet( name ):
6+
print "Hello " + name + "!"
7+
8+
your_name = get_name()
9+
10+
greet( your_name )
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
print ""
2+
print "Basic Math Operations"
3+
print ""
4+
print "4 + 3 is " + str( 4 + 3 ) # Addition, 4 plus 3
5+
print "4 - 3 is " + str( 4 - 3 ) # Subtraction, 4 minus 3
6+
print ""
7+
print "4 * 3 is " + str( 4 * 3 ) # Multiplication, 4 times 3
8+
print "4 ** 3 is " + str( 4 ** 3 ) # Exponentiation, 4 to the 3rd power
9+
print ""
10+
print "4 / 3 is " + str( 4 / 3 ) # Division, 4 divided by 3. Rounds down to integer
11+
print "4 % 3 is " + str( 4 % 3 ) # Modulo, remainder of 4 divided by 3
12+
print ""
13+
print "4.0 / 3 is " + str( 4.0 / 3 ) # Division, 4 divided by 3, not rounded
14+
print ""
15+
# your_number = raw_input( "Enter a number: " )
16+
# answer = float( your_number ) * 3 + 2
17+
# print "Your result is " + str( answer )
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
print ""
2+
print "Comparisons"
3+
print ""
4+
print "4 > 3 is " + str( 4 > 3 ) # 4 greater than 3
5+
print "4 < 3 is " + str( 4 < 3 ) # 4 less than 3
6+
print "4 == 3 is " + str( 4 == 3 ) # 4 equal to 3
7+
print "4 >= 3 is " + str( 4 >= 3 ) # 4 greater than or equal to 3
8+
print "4 <= 3 is " + str( 4 <= 3 ) # 4 less than or equal to 3
9+
print "4 != 3 is " + str( 4 != 3 ) # 4 not equal to 3
10+
print ""
11+
print "Boolean Operators - not, and, or"
12+
print ""
13+
print "not True is " + str( not True )
14+
print "not False is " + str( not False )
15+
print ""
16+
print "True and True is " + str( True and True )
17+
print "True and False is " + str( True and False )
18+
print "False and False is " + str( False and False )
19+
print ""
20+
print "True or True is " + str( True or True )
21+
print "True or False is " + str( True or False )
22+
print "False or False is " + str( False or False )
23+
print ""
24+
print "not ( False or (False and True) ) is " + str( not ( False or (False and True) ) )
25+

python_intro/python_examples/7_if.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
my_name = "Raspberry Pi"
2+
print "My name is " + my_name
3+
4+
your_name = raw_input( "What is your name? " )
5+
6+
# Check to see if your_name was entered
7+
if len( your_name ) == 0:
8+
# name was not entered
9+
print "I really really really would like to know your name."
10+
your_name = raw_input( "What is your name? " )
11+
12+
if len( your_name ) > len( my_name ) :
13+
print "Oh, what a long name you have"
14+
elif len( your_name ) < len( my_name ) : # elif is python for 'else, if'
15+
print "Oh, what a short name you have"
16+
else:
17+
print "Your name is the same length as my name"
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# range( ) creates a list of integers starting at 0
2+
print range( 10 )
3+
print ""
4+
5+
# 'for' sets a variable to each value in a list
6+
for x in range( 5 ):
7+
print "x = " + str(x)
8+
9+
print ""
10+
11+
# 'while' will repeat as long as its condition is True
12+
x = 5
13+
while x > 0:
14+
print "x = " + str(x)
15+
x = x - 1
16+
17+
print ""
18+
19+
# Putting it together
20+
21+
haters_gonna_hate = True
22+
23+
shakes=0
24+
25+
print "I'm just gonna..."
26+
27+
while haters_gonna_hate:
28+
print "shake"
29+
shakes = shakes + 1
30+
if shakes >= 5:
31+
haters_gonna_hate = False
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# get direct access to the datetime library
2+
from datetime import datetime
3+
4+
current_time = datetime.now()
5+
6+
print "The year is " + str( current_time.year )
7+
print "The month is " + str( current_time.month )
8+
print "The day is " + str( current_time.day )
9+
print "The hour is " + str( current_time.hour )
10+
print "The minute is " + str( current_time.minute )
11+
print "The second is " + str( current_time.second )
12+
13+
# you can *import* with this style that does not use *from*
14+
import time
15+
16+
print "Going to sleep for 5 seconds....Zzzzzzz"
17+
18+
start_time = time.time() # time.time() returns the number of seconds since Jan 1, 1970
19+
time.sleep(5) # waits 5 seconds
20+
stop_time = time.time()
21+
22+
nap_time = stop_time - start_time
23+
24+
print "I actually slept for " + str( nap_time ) + " seconds."

raspi/build/01-build.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Getting Started with Raspberry Pi
2+
=================================
3+
4+
#### Objectives
5+
1. **[Build a tiny computer](01-build.md)**
6+
2. [Set it up just so](02-configuring.md)
7+
3. [Explore the Raspbian desktop](03-raspbian-desktop.md)
8+
4. [Learn a little Linux](04-linux-101.md)
9+
10+
# Building a tiny computer
11+
12+
[What is a Raspberry Pi?](https://vimeo.com/90103691) from the [Raspberry Pi Foundation](https://vimeo.com/raspberrypi)
13+
14+
The Raspberry Pi is a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing, and to learn how to program in languages like Scratch and Python. It’s capable of doing everything you’d expect a desktop computer to do, from browsing the internet and playing high-definition video, to making spreadsheets, word-processing, and playing games. What’s more, the Raspberry Pi has the ability to interact with the outside world, and has been used in a wide array of digital maker projects, from music machines and parent detectors to weather stations and tweeting birdhouses with infra-red cameras!
15+
16+
:star: You're going to build one today and use it for the next two weeks!
17+
18+
## Overview of your Raspberry Pi kit
19+
20+
![Photograph of the kit issued to each student](images/kit-annotated.png)
21+
22+
| Part | Notes |
23+
|------|-------|
24+
| Raspberry Pi Model 2 | A tiny machine made just for tinkering |
25+
| HDMI cable | In addition to computer monitors, you may use any TV that has HDMI or composite input as a screen |
26+
| mini-USB Power Supply & Cable | If you have your own Raspi, any mini-USB can be used as long as its specs are XXX |
27+
| Ourlink Wifi Adapter | There are many USB Wifi adapters but this is widely considered to be the best for Raspi |
28+
| Keyboard and Mouse | You can use any USB keyboard and mouse, but you may need to update the Raspi's keyboard configuration |
29+
| MicroSD card | This card has been formatted to contain a Raspberry Pi operating system |
30+
| Electronics Package | These items will be discussed separately |
31+
32+
## Put it all together
33+
34+
* Plug in the keyboard, mouse, and wifi adapter into any three USB ports
35+
* Insert the microSD card into the card slot on the bottom side of the Pi. The lettering on the card should be facing outwards so you can read it.
36+
* Connect the HDMI cable between the Pi and the monitor. Turn on the monitor.
37+
* Plug in the USB power supply into the power strip
38+
* Connect the power supply to the Pi microUSB power input
39+
40+
![Raspberry Pi Assembled](images/connected.jpg)
41+
42+
**:red_circle: The status LEDs on the Pi should light up**
43+
44+
![Boot sequence on screen](images/boot-screen.jpg)
45+
46+
**On the monitor, you will see a lot of text scroll by. This is the computer "booting up"**
47+
48+
# What you learned
49+
* What the various connection ports are for on a Raspberry Pi computer
50+
* How to assemble and power up a Raspberry Pi computer
51+
52+
# Challenges
53+
* None
54+
55+
# Resources
56+
* [What is Raspberry Pi](https://www.raspberrypi.org/help/what-is-a-raspberry-pi/)
57+
* [Shop for Raspberry Pi and accessories](http://www.adafruit.com/category/105)
58+

raspi/build/02-configuring.md

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Getting Started with Raspberry Pi
2+
=================================
3+
4+
#### Objectives
5+
1. [Build a tiny computer](01-build.md)
6+
2. **[Set it up just so](02-configuring.md)**
7+
3. [Explore the Raspbian desktop](03-raspbian-desktop.md)
8+
4. [Learn a little Linux](04-linux-101.md)
9+
10+
# Configuring the Raspberry Pi
11+
12+
The Raspberry Pi operating system needs a few hints, provided by you, as to how it should behave. If you have used a PC computer before, this is similar to changing settings in the BIOS.
13+
14+
## Introducing Raspi-config
15+
16+
When you first boot up, the system will launch **raspi-config**
17+
18+
![Raspberry Pi Software Configuration Tool](images/raspi-config.png)
19+
20+
**Raspi-config** is a text-based application, so you can't use your mouse to navigate. Instead, use the **Arrow** and **Tab** keys to move between fields, **Return** to select, and use **Esc** to cancel. You can always get back to the main page by tapting Esc a couple of times!
21+
22+
:star: You can access this screen in the future to make other changes by typing `sudo raspi-config` in any Terminal window (more on Terminals later...)
23+
24+
### Expand the file system
25+
26+
The Raspbian operating system takes up just a small portion of the available storage space, but we don't start off knowing how big of a disk it was installed on. So, the first time we boot up from a new SD card we need to let the system know how much room there is for programs and doge pics.
27+
28+
* Move the red cursor to **1 Expand Filesystem** using the arrow keys and tap **Return**. You should see a message go by the the filesystem will be enlarged next time you reboot. Simple right?
29+
30+
![Raspberry Doge](images/doge.jpg)
31+
32+
### Booting to a Graphical Desktop
33+
34+
Some systems launch to a powerful text interface by default because this saves precious memory and processor power. For now, we want to make sure the Raspi starts up in a friendly desktop environment.
35+
36+
* Move the red cursor to **3 Enable Boot to Desktop/Scratch**, tap **Return**, and select **Desktop Log in as user 'pi' at the graphical desktop**. tap **Return**.
37+
38+
### Setting Timezone and Keyboard Type
39+
40+
Raspberry Pis are British computers and as such default to Greenwich Mean Time (GMT) and a UK keyboard layout. The former will make the Pi think its 5-6 hours later than it is and the latter will make some of your keys act funny when using an American keyboard.
41+
42+
* Move the red cursor to **4 Internationalisation Options**, tap **Return**, select **I2 Change Timezone**, and tap **Return** again.
43+
* After a brief pause, you will see a menu called **Configuring tzdata**. Select **US** and then **Central**, then tap **Return**
44+
* From the main **raspi-config** page, choose **4 Internationalisation Options** again. This time, select **I3 Change Keyboard Layout** then make the following selections:
45+
* Keyboard model: Generic 101-key PC
46+
* Keyboard layout: English (US)
47+
* Key to function as AltGr: The default for the keyboard layout
48+
* Compose key: No compose key
49+
* Use Control+Alt+Backspace to termine the X server: Yes
50+
51+
### Renaming your Pi
52+
53+
Out of the box, all Pis are named **raspberrypi** on the network. This is going to get confusing, so you are going to give your Pi its own unique name.
54+
55+
* Move the cursor to **8 Advanced Options**, tap **Return**, then navigate to **A2 Hostname** and tap **Return** again. Read the message about valid characters, tap **Return** one more time.
56+
* Enter a new name for your Pi in the box labeled "Please enter a hostname". When you're ready to end, use **Tab** to navigate to the **OK** field and tap **Return**
57+
58+
#### Rules of the Road
59+
60+
1. You can only use the characters a-z, 0-9, and the hyphen
61+
2. Try to keep your names short because you and others will have to type them
62+
3. :exclamation: All names used in our workshop have to be appropriate for a classroom setting
63+
64+
### Enabling SPI
65+
66+
SPI is a special interface that will be used later in the workshop. We need to turn it on in **raspi-config**.
67+
68+
* Go to **8 Advanced Options** again and tap **Return**. Select **A6 SPI** and when asked if you would like the SPI interface to be enabled, select **Yes**. When asked if you would like the SPI kernel module to be loaded by default, again select **Yes**.
69+
70+
### Restarting
71+
72+
Most of the changes you made won't take effect until the computer restarts. So, let's do that now from within **raspi-config**
73+
74+
* Navigate the cursor to **Finish** and tap **Return**, then watch the system restart. It should only take a few seconds. Then, you will be ready to explore the desktop!
75+
76+
![Raspbian Desktop](images/desktop-start.jpg)
77+
78+
**The Raspbian desktop will appear after you reboot from raspi-config**
79+
80+
## Connecting to Wifi
81+
82+
There's a lot of corners to explore on the Raspbian desktop, but the first thing most folks want to do is connect to the Internet. If you have access to a wired, or **Ethernet**, network you can connect to it via the **Ethernet Port** on the Raspi using a cable. Most of us use wireless, or **Wifi** connections and so shall we in our workshop.
83+
84+
* In the top right corner of the screen, click on the networking icon. It will either look like a pair of computers or a common "Wifi" signal icon.
85+
86+
![CODE@TACC SSID](images/01-find-wifi.jpg)
87+
88+
**Select the CODE@TACC network. You will not have access to the others.**
89+
90+
* Enter either this access key **0123456789** or one provided to you by the instructors
91+
92+
![CODE@TACC WPA2](images/02-enter-wpa2.jpg)
93+
94+
**If you entered the key correctly, when you click on the Wifi icon, it will show your Raspi to be connected to the CODE@TACC network**
95+
96+
![CODE@TACC connected](images/03-connected-wifi.jpg)
97+
98+
# What you learned
99+
* How to use navigate inside a "screen-based" application
100+
* Finding and configuring various options inside **raspi-config**
101+
* How to rename a Raspberry Pi
102+
* Connecting a Raspberry Pi to a Wifi internet connection
103+
104+
# Challenges
105+
* None
106+
107+
# Resources

raspi/build/03-raspbian-desktop.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Getting Started with Raspberry Pi
2+
=================================
3+
4+
#### Objectives
5+
1. [Build a tiny computer](01-build.md)
6+
2. [Set it up just so](02-configuring.md)
7+
3. **[Explore the Raspbian desktop](03-raspbian-desktop.md)**
8+
4. [Learn a little Linux](04-linux-101.md)
9+
10+
# Explore the Raspbian desktop
11+
12+
Introduction and background
13+
14+
## Topic 1
15+
16+
Connecting to Wifi
17+
Change the time zone
18+
Change keyboard mapping
19+
20+
# Challenges
21+
* Run raspi-config after booting. Change the password for the "pi" user (but don't forget to write it down).
22+
* Connect to the "Challenge-Mode" network. The password is written on the whiteboard. Don't forget to re-connect to CODE@TACC network afterwards.
23+
24+
# Resources
25+

0 commit comments

Comments
 (0)