Python Programming Turtle Race

#!/bin/python3
from turtle import *
from random import randint
speed(0)
penup()
goto(-140,140)
for step in range(15):
write(step,align=’center’)
right(90)
forward(10)
for dashes in range(5):
pendown()
forward(15)
penup()
forward(15)
backward(160)
left(90)
forward(20)
ada = Turtle()
ada.color(‘red’)
ada.shape(‘turtle’)
ada.penup()
ada.goto(-160,100)
ada.pendown()
bob =Turtle()
bob.color(‘blue’)
bob.shape(‘turtle’)
bob.penup()
bob.goto(-160,70)
bob.pendown()
coc =Turtle()
coc.color(‘yellow’)
coc.shape(‘turtle’)
coc.penup()
coc.goto(-160,40)
coc.pendown()
dod =Turtle()
dod.color(‘brown’)
dod.shape(‘turtle’)
dod.penup()
dod.goto(-160,10)
dod.pendown()
for turn in range(10):
ada.right(36)
bob.left(36)
coc.right(36)
dod.left(36)
for turn in range(100):
ada.forward(randint(1,5))
bob.forward(randint(1,5))
coc.forward(randint(1,5))
dod.forward(randint(1,5))
#write(0)
#forward(20)
#write(1)
#forward(20)
#write(2)
#forward(20)
#write(3)
#forward(20)
#write(4)
#forward(20)
#write(5)
#forward(20)
#write(6)
#forward(20)
#write(7)
#forward(20)
#write(8)
#forward(20)
#write(9)
#forward(20)
#write(10)
#forward(20)
#write(11)
#forward(20)
#write(12)
#forward(20)
#write(13)
#forward(20)
#write(14)
#forward(20)
#write(15)
#forward(20)
#write(16)
#forward(20)

Raspberry PI Lab

Created on Sun Nov 02 10:30:22 2018
Team Lead Name:
HW Team Member Names:
SW Team Member Names:
”’
###Part (1): import the GPIO library( DO NOT change the code in this part.)
import RPi .GPIO as GPIO
import time

###Part (2): Assign GPIO ports to each binary number
###Use GPIO ports 12,16,20,21. Reference the Lab Instructions

num1=[12] #(GPIO12 use for bit#1 (2^0=1))
num2=[16] #(GPIO16 use for bit#2 (2^1=2))
num3=[12,16] #(Decimal number 3 is 2+1, so we need GPIO12,16)
num4=[20] #(GPIO20 use for bit#3 (2^2=4))
num5=[20,12] #(Decimal number 5 is 4+1, so we need GPIO20, 12)
num6=[20,16]
num7=[20,12,16] #(Decimal number 7 is 4+2+1,so we need combine GPIO20, 16, 12)

num8=[21] #(Add your code for num8-num14)
num9=[21,12]
num10=[21,16]
num11=[21,16,12]
num12=[21,20]
num13=[21,20,12]
num14=[21,20,16]
num15=[21,20,16,12] #(Decimal number 15 is 8+4+2+1, so we use GPIO21,20,12,16)

### Part (3): set GPIO 12,16,20,21 as outputs. (DO NOT change the code in this part.)
GPIO.setmode(GPIO.BCM)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(16,GPIO.OUT)
GPIO.setup(20,GPIO.OUT)
GPIO.setup(21,GPIO.OUT)

###Part (4): A “while loop” code that displays LED lights from decimal 1 to 15 and repeats by looping.

while True: #Run while “true”
GPIO.output(num1,GPIO.HIGH) #num1 sets electrical signals ON for decimal 1.
time.sleep(2) #The electrical signals will stay on for 2 seconds.
GPIO.output(num1,GPIO.LOW) #After 2 seconds, num1 signals are OFF.
time.sleep(2)

GPIO.output(num2,GPIO.HIGH)
time.sleep(2)
GPIO.output(num2,GPIO.LOW)
time.sleep(2)

GPIO.output(num3,GPIO.HIGH)
time.sleep(2)
GPIO.output(num3,GPIO.LOW)
time.sleep(2)

GPIO.output(num4,GPIO.HIGH)
time.sleep(2)
GPIO.output(num4,GPIO.LOW)
time.sleep(2)

GPIO.output(num5,GPIO.HIGH)
time.sleep(2)
GPIO.output(num5,GPIO.LOW)
time.sleep(2)

GPIO.output(num6,GPIO.HIGH)
time.sleep(2)
GPIO.output(num6,GPIO.LOW)
time.sleep(2)

GPIO.output(num7,GPIO.HIGH)
time.sleep(2)
GPIO.output(num7,GPIO.LOW)
time.sleep(2)

GPIO.output(num8,GPIO.HIGH)
time.sleep(2)
GPIO.output(num8,GPIO.LOW)
time.sleep(2)

GPIO.output(num9,GPIO.HIGH)
time.sleep(2)
GPIO.output(num9,GPIO.LOW)
time.sleep(2)

GPIO.output(num10,GPIO.HIGH)
time.sleep(2)
GPIO.output(num10,GPIO.LOW)
time.sleep(2)

GPIO.output(num11,GPIO.HIGH)
time.sleep(2)
GPIO.output(num11,GPIO.LOW)
time.sleep(2)

GPIO.output(num12,GPIO.HIGH)
time.sleep(2)
GPIO.output(num12,GPIO.LOW)
time.sleep(2)

GPIO.output(num13,GPIO.HIGH)
time.sleep(2)
GPIO.output(num13,GPIO.LOW)
time.sleep(2)

GPIO.output(num14,GPIO.HIGH)
time.sleep(2)
GPIO.output(num14,GPIO.LOW)
time.sleep(2)

GPIO.output(num15,GPIO.HIGH)
time.sleep(2)
GPIO.output(num15,GPIO.LOW)
time.sleep(2)

###Part (5): The code below is commented within a pair of ”’.
#The code uses LEDs to blink for an example TUID.
GPIO.output(num9,GPIO.HIGH)
time.sleep(2)
GPIO.output(num9,GPIO.LOW)
time.sleep(2)

GPIO.output(num1,GPIO.HIGH) #num1 sets electrical signals ON for decimal 1.
time.sleep(2) #The electrical signals will stay on for 2 seconds.
GPIO.output(num1,GPIO.LOW) #After 2 seconds, num1 signals are OFF.
time.sleep(2)

GPIO.output(num5,GPIO.HIGH)
time.sleep(2)
GPIO.output(num5,GPIO.LOW)
time.sleep(2)

GPIO.output(num2,GPIO.HIGH)
time.sleep(2)
GPIO.output(num2,GPIO.LOW)
time.sleep(2)

GPIO.output(num8,GPIO.HIGH)
time.sleep(2)
GPIO.output(num8,GPIO.LOW)
time.sleep(2)

GPIO.output(num4,GPIO.HIGH)
time.sleep(2)
GPIO.output(num4,GPIO.LOW)
time.sleep(2)

GPIO.output(num8,GPIO.HIGH)
time.sleep(2)
GPIO.output(num8,GPIO.LOW)
time.sleep(2)

GPIO.output(num5,GPIO.HIGH)
time.sleep(2)
GPIO.output(num5,GPIO.LOW)
time.sleep(2)

GPIO.output(num4,GPIO.HIGH)
time.sleep(2)
GPIO.output(num4,GPIO.LOW)
time.sleep(2)
”’
#example: #TUID:915334

GPIO.output(num9,GPIO.HIGH)
time.sleep(2)
GPIO.output(num9,GPIO.LOW)
time.sleep(2)

GPIO.output(num1,GPIO.HIGH)
time.sleep(2)
GPIO.output(num1,GPIO.LOW)
time.sleep(2)

GPIO.output(num5,GPIO.HIGH)
time.sleep(2)
GPIO.output(num5,GPIO.LOW)
time.sleep(2)

GPIO.output(num3,GPIO.HIGH)
time.sleep(2)
GPIO.output(num3,GPIO.LOW)
time.sleep(2)

GPIO.output(num3,GPIO.HIGH)
time.sleep(2)
GPIO.output(num3,GPIO.LOW)
time.sleep(2)

GPIO.output(num4,GPIO.HIGH)
time.sleep(2)
GPIO.output(num4,GPIO.LOW)
time.sleep(2)
”’
###Part (6): Add your code below to display LEDs for your own TUID

9(21,12)

1(12)

5(20,12)

5(20,12)

5(20,12)

3(21,20,12)

6(20,16)

7(20,16,12)

1(12)

 

 

Controlling 1s and 0s

Transistors — switchesThe switch is a machine that can control on and off. He is like a source of information. When he is off, the information it provides is 0. When the switch turns to on, it provides 1 in the system.

Truth table :A table of all possible states between logical event inputs and outputs. A table listing the true and false values of the propositional formula. Usually 1 means true and 0 means false. It shows all the possibilities of things.

Boolean AlgebraIt is a kind of logic. It only has 1 and 0 to indicate true and false. It can use “AND” “OR” “NOT” to visually represent the logic of one thing, it can use Ture table to show the intersection and merge of information.

A logic gate is a basic component on a circuit. A simple logic gate can be made up of transistors. The combination of these transistors allows the two signals to represent logically “true” and “false” or binary 1 and 0, respectively, to achieve logical operations.

 

Bits, Bytes, and the Representation of Information

Computers are an important tool in our daily lives. It has its own way of working and logic. Bite and byte are the way and logic it works.

Bits: Bit is the construction of binary digit.  It was coined by Tukey in the mid-1940s. It can represent two sides of things. For example, on/off, right/wrong, It only has 2 number(1,0)  and replaces any number. For example, 1=001 2=010 3=011 4=100 5=101 6=110 7=111 0=000.A bit has two value of number, like one opening and closing, two bits have four value of number, three bits have eight value of number, how many values exist when there are N bits? 2^N is calculated as 2*1=2(2^1), 2*2=4(2^2), 2*3=8(2^3).

Bytes: 1byte=8 Bits. that means we have 256 different characters appear. It can represent a character (A~Z), a number (0~9), or a symbol (,.?!%&+-*/), which is the basic unit of data stored in memory. Bits and byte are two different things. Bits can be understood as the information itself, and the byte is a collection of information. For example, Tokoyo is an English word and it is 1 byte. And 東京 is a Japanese world it is 4bytes.

Bit and Byte Explained in 6 Minutes – What Are Bytes and Bits? This video explains the difference between bit and byte in a simple way, and the examples are very easy to understand. In the 45th second of the video, it began to explain what the bit is and how it works. At video 3:35, it starts to explain the byte

https://www.youtube.com/watch?v=y45v5SLjxaM

HTTP:// HTTPS://www.youtube.com/watch V = y45v5SLjxaM

Continue reading Bits, Bytes, and the Representation of Information

Website Entry on What’s in a Computer

Cpu full name Central Processing Unit. Cpu is the core component of the computer, only as big as a matchbox, so thick as dozens of pieces of paper, but it is the computing core and control core of a computer. The operating speed unit of the CPU is Ghz. It determines the running speed of the computer. With the development of the computer, it has developed from MHZ to GHZ (1GHZ=10^3MHZ=10^6KHZ= 10^9HZ)

RAM is usually used as an operating system or other temporary storage media for running programs, also known as system memory. Just like the memory stick in the computer, if the memory capacity is larger, the computer has more memory to store the tasks running at the same time, so the faster the system responds.

The disk is the medium used by computers to store data. The floppy disk used in early computers was only 100kb or 100mb, but the current computer hard disk capacity can reach 500GB.

 

The video below shows all the possible parts of the computer and explains what they do, and shows how each part works together and how a computer works. For example, it explains the relationship and role of RAM and DISK and shows how they relate to the CPU and how it works.

 

https://www.youtube.com/watch?v=ExxFxD4OSZ0

Hello world!

My name is Jiayuan Zhang. I  am a student at Temple University and Digital world 2020 section 009.  I come from China. I’m 20 years old.  I like to travel and play video games during my free time.