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
#I McTavish | |
#Sept 21, 2016 | |
#Variables - demonstrate variables | |
#Declare an integer variable | |
my_age = 17 | |
#output my_age | |
print(my_age) | |
#output type of data | |
print(type(my_age)) |
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
def output_variables(): | |
print("w:", w, "Type:", type(w)) | |
print("x:", x, "Type:", type(x)) | |
print("y:", y, "Type:", type(y)) | |
print("z:", z, "Type:", type(z)) | |
w = 3.2 | |
x = 3.8 | |
y = -3.2 | |
z = -3.8 |
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 pickle #used to serialize the data | |
import os.path | |
#Comment this code | |
#global variables | |
songs_and_bands = {"Drive": "Judge Jackson"} | |
def open_file(): | |
global songs_and_bands #get global variable | |
if os.path.isfile('songs_and_bands.dat'): | |
binary_file=open('songs_and_bands.dat','rb') |
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
oopics4uunit2 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
<component name="TestRunnerService"> | |
<option name="PROJECT_TEST_RUNNER" value="Unittests" /> | |
</component> |
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
price = float(input("What is the price? ")) | |
#sample if | |
if price > 100: | |
print("You qualify for a disount of ",format(price*0.10,".2f")) | |
#if statement with else | |
if price < 0: | |
print("That price is invalid") | |
else: | |
print("Proceed with the sale!") |
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
#Name | |
#date | |
#goal: create a program that displays a square using the following pattern | |
""" | |
rbrbrb | |
bbrbrb | |
rrrbrb | |
bbbbrb | |
rrrrrb | |
bbbbbb |
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
#I McTavish | |
#Oct 28, 2016 | |
#Demonstrate Lists | |
goals_game1 = 3 | |
goals_game2 = 5 | |
goals_game3 = 2 | |
goals_game4 = 1 | |
goals_game5 = 0 |
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
#I McTavish | |
#Oct 28, 2016 | |
#Demonstrate Lists | |
goals_game = [3,5,2,1,0] | |
totalgoals = 0; | |
for x in range(len(goals_game)): | |
totalgoals += goals_game[x] | |
print(totalgoals) |
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
#I McTavish | |
#Oct 27, 2016 | |
#Use Lists | |
#Create a list of strings | |
list1 = ['Drew','Sherriee','Lonny','Stacee'] | |
#output full list | |
print(list1) |
OlderNewer