This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
f = open('scores.csv','r') | |
reader = csv.reader(f) #Start the reader engine | |
scorelist = [row for row in reader] #Get all the rows from the file read them into a 2d list | |
#Just to prove that it has worked, let's print out the list in a pretty manner. | |
#Using list unzipping like this makes your program really easy to read. | |
for fname,lname,score in scorelist: | |
print("First name:", fname, "Last name:",lname,"Score:",score) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bob,jones,20 | |
fred,wilson,30 | |
sarah,smith,100 | |
harry,harrington,5000 | |
bill,billington,300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bob | jones | 20 | |
---|---|---|---|
fred | wilson | 30 | |
sarah | smith | 100 | |
harry | harrington | 5000 | |
bill | billington | 300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Open a file and print out all the contents. | |
f = open("myfile.txt","r") | |
for line in f: | |
print("line) | |
#Read one light from the file and save it to a variable. | |
f = open("highscore.txt","r") | |
score = f.readline() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import time,math | |
mc = minecraft.Minecraft.create() | |
mc.postToChat("Rainbow World") | |
pos = mc.player.getTilePos() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import random, time | |
mc = minecraft.Minecraft.create() | |
mc.postToChat("Minecraft Volcano!") | |
mc.setBlocks(-100,0,-100,100,50,100,block.AIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mcpi.minecraft as minecraft | |
import mcpi.block as block | |
import time,math | |
mc=minecraft.Minecraft.create() | |
#mc.player.setTilePos(1,1,1) | |
mc.setBlocks(0,0,0,100,100,100,block.AIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, os | |
os.system('clear') | |
print("*** Welcome to the month app ***") | |
month = input("What month is it?").lower() | |
# .lower() converts the input to lowercase e.g. January >>>> january | |
if month == "january": | |
print("Brr!!! It's cold in january") | |
elif month in ["july","august"]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ev3dev.ev3 import * | |
import time | |
a = LargeMotor('outA') | |
b = LargeMotor('outB') | |
c = MediumMotor('outC') | |
ANGLEMULTI = 15 | |
def turnRight(x): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from microbit import * | |
#Let's create a baby pink color using analogue settings! | |
pin0.write_analog(1020) | |
pin1.write_analog(620) | |
pin1.write_analog(1020) |