Compare commits

..

No commits in common. "33badb8c979649127adc7428c009d06606391f4c" and "c464c77b9d0d65464e9de972df3007015fbe3c4d" have entirely different histories.

21 changed files with 0 additions and 425 deletions

View File

@ -4,6 +4,4 @@
### This is a third header ### This is a third header
## This is a new header level 2
Temp repository Temp repository

View File

@ -1,32 +0,0 @@
program01 = '''
Program: if01
This program demonstrates the conditional tests used in Python.
'''
print(program01)
a = 4
b = 7
c = 7
print(f"a = {a}\nb = {b}\nc = {c}\n")
print(f"a == b {a==b}")
print(f"a != b {a!=b}")
print(f"a < b {a<b}")
print(f"a <= b {a<=b}")
print(f"a > b {a>b}")
print(f"a >= b {a>=b}")
print("\n")
print(f"c == b {c==b}")
print(f"c != b {c!=b}")
print(f"c < b {c<b}")
print(f"c <= b {c<=b}")
print(f"c > b {c>b}")
print(f"c >= b {c>=b}")

View File

@ -1,39 +0,0 @@
# if statement example
if 22 > 7:
print("22 is greater than 7")
print("A better method to define the code ...")
# Use variables in the if statement and print
data1 = 22
if data1 > 7:
print(f"{data1} is greater than 7")
# Or this form
print("And another method to define the code ...")
data1 = 22
data2 = 7
if data1 > data2:
print(f"{data1} is greater than {data2}")
data1 = 6
data2 = 7
if data1 > data2:
print(f"{data1} is greater than {data2}")
else:
print(f"{data1} is less than or equal {data2}")
print("Program ended")

View File

@ -1,16 +0,0 @@
# if..else statement example
x = 7
print(f"{x} is equal to 7?")
if x == 7:
print("Yes")
else:
print("No")
# if..else statement example
x = 5
print(f"{x} is equal to 7?")
if x == 7:
print("Yes")
else:
print("No")

View File

@ -1,23 +0,0 @@
#!/usr/bin/python3
# Program: if02
# Lists of numbers. These could be integers or floats.
intList = [7, 2, 16, 18, 12, 21]
# Print the list and the length
print(intList," length = ",len(intList))
print(f"Print each value in the list")
counter = 0
for item in intList:
print(f"intList[{counter}] = {item:2d}")
counter += 1
cutoff = 13
print(f"Print each value in the list >= {cutoff}")
counter = 0
for item in intList:
if(item >= cutoff):
print(f"intList[{counter}] = {item:2d}")
counter += 1

View File

@ -1,25 +0,0 @@
#!/usr/bin/python3
# Program: if03
# Lists of numbers. These could be integers or floats.
intList = [7, 2, 16, 18, 12, 21]
# Print the list and the length
print(intList," length = ",len(intList))
print(f"Print each value in the list")
counter = 0
for item in intList:
print(f"intList[{counter}] = {item:2d}")
counter += 1
cutoff = 13
print(f"Print each value in the list >= {cutoff}")
counter = 0
for item in intList:
if(item >= cutoff):
print(f"intList[{counter}] = {item:2d}")
else:
print(f"========> intList[{counter}] = {item:2d} is less than {cutoff}")
counter += 1

View File

@ -1,7 +0,0 @@
# consider the following line from the autoloan program:
principal = float(input("Enter a value for the principal: "))
print(f"You entered the value {principal}")

View File

@ -1,16 +0,0 @@
# consider the following line from the autoloan program:
principal = float(input("Enter a value for the principal: "))
if(principal < 5000.) or (principal >120000.00):
print(f"The loan value {principal} is outside the allowed limits.")
exit(-1)
rate = float(input("Enter a value for the interest rate (7 for 7%): "))
numberOfYears = float(input("Enter the number of years for the loan: "))
print(f"You entered the principal value {principal}")
print(f"You entered the rate value {rate}%")
print(f"You entered the loan term value {numberOfYears} years")

View File

@ -1,28 +0,0 @@
message01 = '''
Mass Excise Tax Fees
====================
The tax depends on the vehicle age. For this program we only calculate the
excise tax on the first year of purchase.
https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm
Vehicle Age Percentage of List Price
In the year preceding the model year
(brand new car released before model year) 50%
In the model year 90%
In the second year 60%
In the third year 40%
In the fourth year 25%
In the fifth and succeeding years 10%
'''
print(message01)
# Tax table for excise tax by year.
exciseTaxRateTable = [.5, .9, .6, .4, .25, .10, .10, .10, .10, .10]
year = -1 # Indicates a date prior to the model year; i.e you bought a model year 2024 in year 2023.
for exciseTaxRate in exciseTaxRateTable:
print(f"{year:2d} {exciseTaxRate:.2f} {exciseTaxRate:.0%}")
year += 1 # Shorthand for year = year + 1
print("Access excise tax rate by index")

View File

@ -1,31 +0,0 @@
message01 = '''
Mass Excise Tax Fees
====================
The tax depends on the vehicle age. For this program we only calculate the
excise tax on the first year of purchase.
https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm
Vehicle Age Percentage of List Price
In the year preceding the model year
(brand new car released before model year) 50%
In the model year 90%
In the second year 60%
In the third year 40%
In the fourth year 25%
In the fifth and succeeding years 10%
'''
print(message01)
# Tax table for excise tax by year.
exciseTaxRateTable = [.5, .9, .6, .4, .25, .10, .10, .10, .10, .10]
print("Access excise tax rate by index")
yearIndex = 2
print(f"year = {yearIndex} rate = {exciseTaxRateTable[yearIndex]}")
yearIndex = 4
print(f"year = {yearIndex} rate = {exciseTaxRateTable[yearIndex]}")
yearIndex = 7 # set to 9 or more and the program will fault
print(f"year = {yearIndex} rate = {exciseTaxRateTable[yearIndex]}")

View File

@ -1,30 +0,0 @@
message01 = '''
Mass Excise Tax Fees
====================
The tax depends on the vehicle age. For this program we only calculate the
excise tax on the first year of purchase.
https://www.sec.state.ma.us/divisions/cis/tax/motor-excise.htm
Vehicle Age Percentage of List Price
In the year preceding the model year
(brand new car released before model year) 50%
In the model year 90%
In the second year 60%
In the third year 40%
In the fourth year 25%
In the fifth and succeeding years 10%
'''
print(message01)
# Tax table for excise tax by year.
exciseTaxRateTable = [.5, .9, .6, .4, .25, .10, .10, .10, .10, .10]
yearIndex = -1 # Indicates a date prior to the model year; i.e you bought a model year 2024 in year 2023.
# Change the 8 to 10. The program will fault.
while yearIndex <= 8:
print(f"{yearIndex:2d} {exciseTaxRateTable[yearIndex]}")
yearIndex += 1 # Shorthand for yearIndex = yearIndex + 1

View File

@ -1,16 +0,0 @@
#!/usr/bin/python3
# grades01
# List element manipulation.
scores = [75, 95, 90, 87, 99, 100, 97]
# This is unnecessary and just here for debugging.
print(scores)
# We will sum the scores. Initialize sum value to zero then add each value to the sum.
sum = 0
for score in scores:
sum = sum + score
print("The sum of the seven scores is ",sum)
print("The average of the seven scores is ",sum/7)

View File

@ -1,15 +0,0 @@
#!/usr/bin/python3
# grades02
# List element manipulation.
scores = [75, 95, 90, 87, 99, 100, 97, 100]
numberOfScores = len(scores)
# We will sum the scores. Initialize sum value to zero then add each value to the sum.
sum = 0
for score in scores:
sum = sum + score
print(f"The sum of the {numberOfScores} scores is {sum:.2f}")
print(f"The average of the {numberOfScores} scores is {sum/numberOfScores:.2f}")

View File

@ -1,23 +0,0 @@
#!/usr/bin/python3
# grades03
# List element manipulation.
numberOfScores = int(input("How many scores do you want to enter? "))
counter = 0 # Start counter at 0
scores = [] # Create an empty list
while(counter < numberOfScores):
nextScore = float(input("Enter the next value: "))
scores.append(nextScore)
counter += 1
# This is unnecessary and just here for debugging.
print(scores)
# We will sum the scores. Initialize sum value to zero then add each value to the sum.
sum = 0
for score in scores:
sum = sum + score
print(f"The sum of the {numberOfScores} scores is {sum:.2f}")
print(f"The average of the {numberOfScores} scores is {sum/numberOfScores:.2f}")

View File

@ -1,17 +0,0 @@
#!/usr/bin/python3
# Program: list01
# Defining and printing list lengths.
# Lists of text values
dogNames = [ "Harry", "Shenanigans","Katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
# Lists of numbers. These could be integers or floats.
intList = [7, 2, 12, 18, 16, 21]
# Print the list and the length
print("Print the length of the lists.")
print (dogNames," length = ",len(dogNames))
print(intList," length = ",len(intList))

View File

@ -1,21 +0,0 @@
#!/usr/bin/python3
# Program: list02
# Lists of text values
dogNames = [ "Harry", "Shenanigans","Katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
firstNames = ["edward","david", "Bob","mary","alice"]
# Print the list and the length
print("Print the length of the lists.")
print (dogNames," length = ",len(dogNames))
print(firstNames," length = ",len(firstNames))
print("\n")
# Another way to think of the for loop is to read it as
# "Select the next element from the list, put it into the variable
# item, the do whatever you like with that one value in item".
# The for loop ends when the entire list has been processed.
for item in dogNames:
print(item)

View File

@ -1,11 +0,0 @@
#!/usr/bin/python3
# Program: list03
# Run this code in the visualizer in a web browser at
# https://pythontutor.com/visualize.html#mode=edit
# Lists of text values
dogNames = [ "Harry", "Shenanigans","Katrina","Tanner","Yukon Jack", "Colorado","Mandy", "Gimli"]
for item in dogNames:
print(item)

View File

@ -1,16 +0,0 @@
#!/usr/bin/python3
# Program: list04
# Lists of text values
dogNames = [ "Harry", "Shenanigans","Katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
# Print the list and the length
print("Print the length of the list.")
print (dogNames," length = ",len(dogNames),"Type =",type(dogNames))
print("\n")
for item in dogNames:
print(f"{item:14s} {type(item)}")
print("\nDone!")

View File

@ -1,15 +0,0 @@
# This code is based on: https://www.w3schools.com/python/ref_func_range.asp
x = range(3, 6)
print(f"x = {x}, type = {type(x)}")
# Another way to think of the for loop is to read it as
# "Select the next element from the list or range, put it into the variable
# item, the do whatever you like with that one value in item".
# The for loop ends when the entire list has been processed.
for item in x:
print(item)

View File

@ -1,21 +0,0 @@
# This code is based on: https://www.w3schools.com/python/ref_func_range.asp
x = range(3, 6)
# A range can be converted to a list.
y = list(x)
# Note:
# What is the difference betweeen using range() and an explicit list?
# The main difference is that range calculates the value on the fly. This saves memory
# at the expense of processing speed. The list has each object stored in memory. This saves
# the processing time at the expense of memory usage.
print(f"x = {x}, type = {type(x)}")
for item in x:
print(item)
print(f"y = {y}, type = {type(y)}")
for item in y:
print(item)

View File

@ -1,21 +0,0 @@
# This code is based on: https://www.w3schools.com/python/ref_func_range.asp
# Create a range from 2 to 10 with steps of two
x = range(2, 10, 2)
y = list(x)
# Note:
# What is the difference betweeen using range() and an explicit list?
# The main difference is that range calculates the value on the fly. This saves memory
# at the expense of processing speed. The list has each object stored in memory. This saves
# the processing time at the expense of memory usage.
print(f"x = {x}, type = {type(x)}, length = {len(x)}")
for item in x:
print(item)
print(f"y = {y}, type = {type(y)}, length = {len(y)}")
for item in y:
print(item)