11-04-2025 Lecture Code

This commit is contained in:
Edward Bigos 2025-11-04 08:44:29 -05:00
parent c565f04461
commit eed5c997b5
44 changed files with 99481 additions and 0 deletions

View file

@ -0,0 +1,170 @@
Duration,Pulse,Maxpulse,Calories
60,110,130,409.1
60,117,145,479.0
60,103,135,340.0
45,109,175,282.4
45,117,148,406.0
60,102,127,300.5
60,110,136,374.0
45,104,134,253.3
30,109,133,195.1
60,98,124,269.0
60,103,147,329.3
60,100,120,250.7
60,106,128,345.3
60,104,132,379.3
60,98,123,275.0
60,98,120,215.2
60,100,120,300.0
45,90,112,
60,103,123,323.0
45,97,125,243.0
60,108,131,364.2
45,100,119,282.0
60,130,101,300.0
45,105,132,246.0
60,102,126,334.5
60,100,120,250.0
60,92,118,241.0
60,103,132
60,100,132,280.0
60,102,129,380.3
60,92,115,243.0
45,90,112,180.1
60,101,124,299.0
60,93,113,223.0
60,107,136,361.0
60,114,140,415.0
60,102,127,300.5
60,100,120,300.1
60,100,120,300.0
45,104,129,266.0
45,90,112,180.1
60,98,126,286.0
60,100,122,329.4
60,111,138,400.0
60,111,131,397.0
60,99,119,273.0
60,109,153,387.6
45,111,136,300.0
45,108,129,298.0
60,111,139,397.6
60,107,136,380.2
80,123,146,643.1
60,106,130,263.0
60,118,151,486.0
30,136,175,238.0
60,121,146,450.7
60,118,121,413.0
45,115,144,305.0
20,153,172,226.4
45,123,152,321.0
210,108,160,1376.0
160,110,137,1034.4
160,109,135,853.0
45,118,141,341.0
20,110,130,131.4
180,90,130,800.4
150,105,135,873.4
150,107,130,816.0
20,106,136,110.4
300,108,143,1500.2
150,97,129,1115.0
60,109,153,387.6
90,100,127,700.0
150,97,127,953.2
45,114,146,304.0
90,98,125,563.2
45,105,134,251.0
45,110,141,300.0
120,100,130,500.4
270,100,131,1729.0
30,159,182,319.2
45,149,169,344.0
30,103,139,151.1
120,100,130,500.0
45,100,120,225.3
30,151,170,300.1
45,102,136,234.0
120,100,157,1000.1
45,129,103,242.0
20,83,107,50.3
180,101,127,600.1
45,107,137,
30,90,107,105.3
15,80,100,50.5
20,150,171,127.4
20,151,168,229.4
30,95,128,128.2
25,152,168,244.2
30,109,131,188.2
90,93,124,604.1
20,95,112,77.7
90,90,110,500.0
90,90,100,500.0
90,90,100,500.4
30,92,108,92.7
30,93,128,124.0
180,90,120,800.3
30,90,120,86.2
90,90,120,500.3
210,137,184,1860.4
60,102,124,325.2
45,107,124,275.0
15,124,139,124.2
45,100,120,225.3
60,108,131,367.6
60,108,151,351.7
60,116,141,443.0
60,97,122,277.4
60,105,125,
60,103,124,332.7
30,112,137,193.9
45,100,120,100.7
60,119,169,336.7
60,107,127,344.9
60,111,151,368.5
60,98,122,271.0
60,97,124,275.3
60,109,127,382.0
90,99,125,466.4
60,114,151,384.0
60,104,134,342.5
60,107,138,357.5
60,103,133,335.0
60,106,132,327.5
60,103,136,339.0
20,136,156,189.0
45,117,143,317.7
45,115,137,318.0
45,113,138,308.0
20,141,162,222.4
60,108,135,390.0
60,97,127,
45,100,120,250.4
45,122,149,335.4
60,136,170,470.2
45,106,126,270.8
60,107,136,400.0
60,112,146,361.9
30,103,127,185.0
60,110,150,409.4
60,106,134,343.0
60,109,129,353.2
60,109,138,374.0
30,150,167,275.8
60,105,128,328.0
60,111,151,368.5
60,97,131,270.4
60,100,120,270.4
60,114,150,382.8
30,80,120,240.9
30,85,120,250.4
45,90,130,260.4
45,95,130,270.0
45,100,140,280.9
60,105,140,290.8
60,110,145,300.4
60,115,145,310.2
75,120,150,320.4
75,125,150,330.4
Can't render this file because it has a wrong number of fields in line 29.

View file

@ -0,0 +1,8 @@
DogName,BirthYear,Breed,Color
Harry,2007,Chinook,Buff
Shenanigans,2008,Chinook,Tawney
Mandy,2016,Chinook,Tawney
Tanner,2002,Golden Retriever,Tan
Rusty,2004,Golden Retriever,Tan
Gimli,2022,Chinook,Tawney
Yukon Jack,2020,Chinook,Tawney
1 DogName BirthYear Breed Color
2 Harry 2007 Chinook Buff
3 Shenanigans 2008 Chinook Tawney
4 Mandy 2016 Chinook Tawney
5 Tanner 2002 Golden Retriever Tan
6 Rusty 2004 Golden Retriever Tan
7 Gimli 2022 Chinook Tawney
8 Yukon Jack 2020 Chinook Tawney

View file

@ -0,0 +1,7 @@
# https://www.w3schools.com/python/pandas/pandas_csv.asp
import pandas as pd
df = pd.read_csv('data.csv')
print(df.to_string())

View file

@ -0,0 +1,7 @@
# https://www.w3schools.com/python/pandas/pandas_csv.asp
import pandas as pd
df = pd.read_csv('dogs.csv')
print(df.to_string())

View file

@ -0,0 +1,9 @@
# https://www.w3schools.com/python/pandas/pandas_csv.asp
import pandas as pd
df = pd.read_csv('data.csv')
print(df.head())
print(df.tail())

View file

@ -0,0 +1,35 @@
line = "7/5/2016,123,638.5"
# split line on commas
lineFields = line.split(',')
print(lineFields)
# Individual columns from the spreadsheet
print(lineFields[0], type(lineFields[0]) )
print(lineFields[1], type(lineFields[1]) )
print(lineFields[2], type(lineFields[2]) )
# Convert ISO date --> 20161115 or 2016-1115 or 2016-11-15
dateFields = lineFields[0].split('/')
print(dateFields)
#print(len(dateFields[0]))
#print(len(dateFields[1]))
if(len(dateFields[0]) == 1):
dateFields[0] = "0"+ dateFields[0]
if(len(dateFields[1]) == 1):
dateFields[1] = "0"+ dateFields[1]
print(dateFields)
isoDate = dateFields[2] + dateFields[0] + dateFields[1]
print("ISO Date = ", isoDate)

View file

@ -0,0 +1,11 @@
# Read a csv file from the current directory
# import the csv function library
import csv
filename = "dogs.csv"
with open(filename,'r') as csvfile:
csvData = csv.reader(csvfile,delimiter = ',',quotechar = '"')
for row in csvData:
print(row)

View file

@ -0,0 +1,17 @@
dataHeaders = "id,value,feed_id,created_at,lat,lon,ele"
dataValues = "0FV1TKJ51XRHX03W57F3PVC7K8,77.2,2756158,2025-03-17 18:16:42 UTC,,,"
print(dataHeaders)
headerFields = dataHeaders.split(",")
print(headerFields)
print(dataValues)
valuesFields = dataValues.split(",")
print(valuesFields)
myFields = [valuesFields[3],valuesFields[1]]
print(myFields)

View file

@ -0,0 +1,170 @@
Duration,Pulse,Maxpulse,Calories
60,110,130,409.1
60,117,145,479.0
60,103,135,340.0
45,109,175,282.4
45,117,148,406.0
60,102,127,300.5
60,110,136,374.0
45,104,134,253.3
30,109,133,195.1
60,98,124,269.0
60,103,147,329.3
60,100,120,250.7
60,106,128,345.3
60,104,132,379.3
60,98,123,275.0
60,98,120,215.2
60,100,120,300.0
45,90,112,
60,103,123,323.0
45,97,125,243.0
60,108,131,364.2
45,100,119,282.0
60,130,101,300.0
45,105,132,246.0
60,102,126,334.5
60,100,120,250.0
60,92,118,241.0
60,103,132
60,100,132,280.0
60,102,129,380.3
60,92,115,243.0
45,90,112,180.1
60,101,124,299.0
60,93,113,223.0
60,107,136,361.0
60,114,140,415.0
60,102,127,300.5
60,100,120,300.1
60,100,120,300.0
45,104,129,266.0
45,90,112,180.1
60,98,126,286.0
60,100,122,329.4
60,111,138,400.0
60,111,131,397.0
60,99,119,273.0
60,109,153,387.6
45,111,136,300.0
45,108,129,298.0
60,111,139,397.6
60,107,136,380.2
80,123,146,643.1
60,106,130,263.0
60,118,151,486.0
30,136,175,238.0
60,121,146,450.7
60,118,121,413.0
45,115,144,305.0
20,153,172,226.4
45,123,152,321.0
210,108,160,1376.0
160,110,137,1034.4
160,109,135,853.0
45,118,141,341.0
20,110,130,131.4
180,90,130,800.4
150,105,135,873.4
150,107,130,816.0
20,106,136,110.4
300,108,143,1500.2
150,97,129,1115.0
60,109,153,387.6
90,100,127,700.0
150,97,127,953.2
45,114,146,304.0
90,98,125,563.2
45,105,134,251.0
45,110,141,300.0
120,100,130,500.4
270,100,131,1729.0
30,159,182,319.2
45,149,169,344.0
30,103,139,151.1
120,100,130,500.0
45,100,120,225.3
30,151,170,300.1
45,102,136,234.0
120,100,157,1000.1
45,129,103,242.0
20,83,107,50.3
180,101,127,600.1
45,107,137,
30,90,107,105.3
15,80,100,50.5
20,150,171,127.4
20,151,168,229.4
30,95,128,128.2
25,152,168,244.2
30,109,131,188.2
90,93,124,604.1
20,95,112,77.7
90,90,110,500.0
90,90,100,500.0
90,90,100,500.4
30,92,108,92.7
30,93,128,124.0
180,90,120,800.3
30,90,120,86.2
90,90,120,500.3
210,137,184,1860.4
60,102,124,325.2
45,107,124,275.0
15,124,139,124.2
45,100,120,225.3
60,108,131,367.6
60,108,151,351.7
60,116,141,443.0
60,97,122,277.4
60,105,125,
60,103,124,332.7
30,112,137,193.9
45,100,120,100.7
60,119,169,336.7
60,107,127,344.9
60,111,151,368.5
60,98,122,271.0
60,97,124,275.3
60,109,127,382.0
90,99,125,466.4
60,114,151,384.0
60,104,134,342.5
60,107,138,357.5
60,103,133,335.0
60,106,132,327.5
60,103,136,339.0
20,136,156,189.0
45,117,143,317.7
45,115,137,318.0
45,113,138,308.0
20,141,162,222.4
60,108,135,390.0
60,97,127,
45,100,120,250.4
45,122,149,335.4
60,136,170,470.2
45,106,126,270.8
60,107,136,400.0
60,112,146,361.9
30,103,127,185.0
60,110,150,409.4
60,106,134,343.0
60,109,129,353.2
60,109,138,374.0
30,150,167,275.8
60,105,128,328.0
60,111,151,368.5
60,97,131,270.4
60,100,120,270.4
60,114,150,382.8
30,80,120,240.9
30,85,120,250.4
45,90,130,260.4
45,95,130,270.0
45,100,140,280.9
60,105,140,290.8
60,110,145,300.4
60,115,145,310.2
75,120,150,320.4
75,125,150,330.4
Can't render this file because it has a wrong number of fields in line 29.

View file

@ -0,0 +1,3 @@
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!

View file

@ -0,0 +1,8 @@
DogName,BirthYear,Breed,Color
Harry,2007,Chinook,Buff
Shenanigans,2008,Chinook,Tawney
Mandy,2016,Chinook,Tawney
Tanner,2002,Golden Retriever,Tan
Rusty,2004,Golden Retriever,Tan
Gimli,2022,Chinook,Tawney
Yukon Jack,2020,Chinook,Tawney
1 DogName BirthYear Breed Color
2 Harry 2007 Chinook Buff
3 Shenanigans 2008 Chinook Tawney
4 Mandy 2016 Chinook Tawney
5 Tanner 2002 Golden Retriever Tan
6 Rusty 2004 Golden Retriever Tan
7 Gimli 2022 Chinook Tawney
8 Yukon Jack 2020 Chinook Tawney

View file

@ -0,0 +1,8 @@
DogName,BirthYear,Breed,Color
Harry,2007,Chinook,Buff
Shenanigans,2008,Chinook,Tawney
Mandy,2016,Chinook,Tawney
Tanner,2002,Golden Retriever,Tan
Rusty,2004,Golden Retriever,Tan
Gimli,2022,Chinook,Tawney
Yukon Jack,2020,Chinook,Tawney
1 DogName BirthYear Breed Color
2 Harry 2007 Chinook Buff
3 Shenanigans 2008 Chinook Tawney
4 Mandy 2016 Chinook Tawney
5 Tanner 2002 Golden Retriever Tan
6 Rusty 2004 Golden Retriever Tan
7 Gimli 2022 Chinook Tawney
8 Yukon Jack 2020 Chinook Tawney

View file

@ -0,0 +1,5 @@
# https://www.w3schools.com/python/python_file_open.asp
f = open("demofile.txt", "r")
print(f.read())

View file

@ -0,0 +1,9 @@
# https://www.w3schools.com/python/python_file_write.asp
f = open("demofile2.txt", "a")
f.write("Now the file has more content!")
f.close()
#open and read the file after the appending:
f = open("demofile2.txt", "r")
print(f.read())

View file

@ -0,0 +1,10 @@
# https://www.w3schools.com/python/python_file_write.asp
f = open("demofile3.txt", "w")
f.write("Woops! I have deleted the content!")
f.close()
#open and read the file after the overwriting:
f = open("demofile3.txt", "r")
print(f.read())

View file

@ -0,0 +1,39 @@
This is from file dogs-with-hidden-char.csv
Sometimes hidden characters are exported from the spreadsheet program. Run csvline2.py
with the filename set to dogs-with-hidden-char.csv
(base) edbigos@Edwards-MacBook-Pro-4 csvlines % od -bc dogs-with-hidden-char.csv
0000000 357 273 277 104 157 147 116 141 155 145 054 102 151 162 164 150
357 273 277 D o g N a m e , B i r t h
0000020 131 145 141 162 054 102 162 145 145 144 054 103 157 154 157 162
Y e a r , B r e e d , C o l o r
0000040 015 012 110 141 162 162 171 054 062 060 060 067 054 103 150 151
\r \n H a r r y , 2 0 0 7 , C h i
0000060 156 157 157 153 054 102 165 146 146 015 012 123 150 145 156 141
n o o k , B u f f \r \n S h e n a
0000100 156 151 147 141 156 163 054 062 060 060 070 054 103 150 151 156
n i g a n s , 2 0 0 8 , C h i n
0000120 157 157 153 054 124 141 167 156 145 171 015 012 115 141 156 144
o o k , T a w n e y \r \n M a n d
0000140 171 054 062 060 061 066 054 103 150 151 156 157 157 153 054 124
y , 2 0 1 6 , C h i n o o k , T
0000160 141 167 156 145 171 015 012 124 141 156 156 145 162 054 062 060
a w n e y \r \n T a n n e r , 2 0
0000200 060 062 054 107 157 154 144 145 156 040 122 145 164 162 151 145
0 2 , G o l d e n R e t r i e
0000220 166 145 162 054 124 141 156 015 012 122 165 163 164 171 054 062
v e r , T a n \r \n R u s t y , 2
0000240 060 060 064 054 107 157 154 144 145 156 040 122 145 164 162 151
0 0 4 , G o l d e n R e t r i
0000260 145 166 145 162 054 124 141 156 015 012 107 151 155 154 151 054
e v e r , T a n \r \n G i m l i ,
0000300 062 060 062 062 054 103 150 151 156 157 157 153 054 124 141 167
2 0 2 2 , C h i n o o k , T a w
0000320 156 145 171 015 012 131 165 153 157 156 040 112 141 143 153 054
n e y \r \n Y u k o n J a c k ,
0000340 062 060 062 060 054 103 150 151 156 157 157 153 054 124 141 167
2 0 2 0 , C h i n o o k , T a w
0000360 156 145 171
n e y

View file

@ -0,0 +1,7 @@
# https://www.w3schools.com/python/python_file_remove.asp
import os
if os.path.exists("demofile3.txt"):
os.remove("demofile3.txt")
else:
print("The file does not exist")

View file

@ -0,0 +1,6 @@
Date,Quan,Cost,Total
4/8/25,1,$1.00,$1.00
4/8/25,2,$0.97,$1.94
4/8/25,4,$45.00,$180.00
4/8/25,6,$12.00,$72.00
4/8/25,9,$11.00,$99.00
1 Date Quan Cost Total
2 4/8/25 1 $1.00 $1.00
3 4/8/25 2 $0.97 $1.94
4 4/8/25 4 $45.00 $180.00
5 4/8/25 6 $12.00 $72.00
6 4/8/25 9 $11.00 $99.00

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
The columns in the census data correspond to:
Column Data
1 A "Name"
2 Frequency in percent
3 Cumulative Frequency in percent
4 Rank

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
#!/usr/bin/python3
## ============================ One time initializations ========================
#fileName = "testdata.txt" # this generates an error
fileName = "female-first.txt"
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
count = 1
runFlag = True
while(runFlag): # Process while true
# print(count,line.rstrip("\n"))
line = inFile.readline()
if line == "":
runFlag == False
else:
line = line.rstrip("\n")
print(count,line)
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,28 @@
#!/usr/bin/python3
## ============================ One time initializations ========================
fileName = "female-first.txt"
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
count = 1
runFlag = True
while(runFlag): # Process while true
# print(count,line.rstrip("\n"))
line = inFile.readline()
if not (line == ""):
line = line.rstrip("\n")
print(count,line)
count = count + 1
else:
runFlag == False
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,28 @@
#!/usr/bin/python3
## ============================ One time initializations ========================
fileName = "testdata.txt"
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
count = 1
runFlag = True
while(1): # Process while true
line = inFile.readline()
if line == "": # Exit on empty line == end of file
break
line = line.rstrip("\n")
print(count,line)
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,35 @@
#!/usr/bin/python3
import re
## ============================ One time initializations ========================
fileName = "female-first.txt"
outFileName = "female-first.csv"
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
outFile = open(outFileName,'w')
count = 1
runFlag = True
while(1): # Process while true
line = inFile.readline()
if line == "": # Exit on empty line == end of file
break
line = line.rstrip("\n")
line = line.lstrip().rstrip()
print(count,line)
csvLine = re.sub(' +',',',line)
print("\t",csvLine)
outFile.write(csvLine + "\n")
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,25 @@
#!/usr/bin/python3
# See https://stackabuse.com/read-a-file-line-by-line-in-python/
# for more information
# Just try reading it line by line on the first attempt.
fileName = "testdata.txt"
try:
inFile = open(fileName,'r')
count = 1
line = inFile.readline()
line = line.rstrip("\n")
while(line): # Read line and place in variable named line
# print(count,line.rstrip("\n"))
print(count,line)
line = inFile.readline()
line = line.rstrip("\n")
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,38 @@
#!/usr/bin/python3
## ============================ One time initializations ========================
fileName = "female-first.txt"
nameToSearch = input("Enter a first name: ")
nameToSearch = nameToSearch.upper()
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
count = 1
runFlag = True
while(1): # Process while true
line = inFile.readline()
if line == "": # Exit on empty line == end of file
break
line = line.rstrip("\n")
# print(count,line)
fieldList = line.split(" ")
# print(fieldList)
print(fieldList[0],len(fieldList[0]))
if nameToSearch == fieldList[0] :
print("Matched {} = {} at position {}".format(nameToSearch,fieldList[0],count))
break
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

View file

@ -0,0 +1,34 @@
#!/usr/bin/python3
## ============================ One time initializations ========================
fileName = "female-first.txt"
## ============================ Open and process file(s) ========================
try:
inFile = open(fileName,'r')
count = 1
runFlag = True
while(1): # Process while true
line = inFile.readline()
if line == "": # Exit on empty line == end of file
break
line = line.rstrip("\n")
print(count,line)
line = line.replace(" "," ")
print("\t",count,line)
fieldList = line.split(" ")
print(fieldList)
for field in fieldList:
print(field)
count = count + 1
except:
print("Some error occurred. Ending here")
exit(-1)
inFile.close()

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
DogName,BirthYear,Breed,Color
Harry,2007,Chinook,Buff
Shenanigans,2008,Chinook,Tawney
Mandy,2016,Chinook,Tawney
Tanner,2002,Golden Retriever,Tan
Rusty,2004,Golden Retriever,Tan
Gimli,2022,Chinook,Tawney
Yukon Jack,2020,Chinook,Tawney
1 DogName BirthYear Breed Color
2 Harry 2007 Chinook Buff
3 Shenanigans 2008 Chinook Tawney
4 Mandy 2016 Chinook Tawney
5 Tanner 2002 Golden Retriever Tan
6 Rusty 2004 Golden Retriever Tan
7 Gimli 2022 Chinook Tawney
8 Yukon Jack 2020 Chinook Tawney

Binary file not shown.

View file

@ -0,0 +1,23 @@
#!/usr/bin/python3
import sys
# See https://stackabuse.com/read-a-file-line-by-line-in-python/
# for more information
# Just try reading it line by line on the first attempt.
filename = "testxdata.txt"
try:
inFile = open(filename,'r')
count = 1
line = inFile.readline()
line = line.rstrip("\n")
while(line): # Read line and place in variable named line
# print(count,line.rstrip("\n"))
print(count,line)
line = inFile.readline()
line = line.rstrip("\n")
count = count + 1
except:
print(f"The file {filename} cannot be accessed.")
sys.exit(-1)

View file

@ -0,0 +1,29 @@
#!/usr/bin/python3
# See https://stackabuse.com/read-a-file-line-by-line-in-python/
# for more information
# Just try reading it line by line on the first attempt.
try:
inFile = open("dogs.csv",'r')
count = 1
line = inFile.readline()
line = line.rstrip("\n")
# process header
columnNames = line.split(",")
print(columnNames)
while(line): # Read line and place in variable named line
# print(count,line.rstrip("\n"))
print(count,line)
columns = line.split(",")
# print(columns)
counter = 0
while(counter < 4):
print("\t{:12s} {:>20s}".format(columnNames[counter],columns[counter]) )
counter = counter + 1
line = inFile.readline()
line = line.rstrip("\n")
count = count + 1
finally:
inFile.close()

View file

@ -0,0 +1,22 @@
#!/usr/bin/python3
# See https://stackabuse.com/read-a-file-line-by-line-in-python/
# for more information
# Just try reading it line by line on the first attempt.
sampleData = ["Harry", "Colorado", "Shenanigans", "Mandy", "Rusty"]
try:
outFile = open("testdatawrite.txt",'w')
for dog in sampleData:
print(dog)
outFile.writelines(dog+"\n")
except:
print("File write error!")
exit(-1)
# When I get to the end of the file.
#finally:
outFile.close()

View file

@ -0,0 +1,4 @@
Harry,2007
Shenanigans,2010
Katrina,2005
Mandy,2016

View file

@ -0,0 +1,5 @@
Harry
Colorado
Shenanigans
Mandy
Rusty

View file

@ -0,0 +1,5 @@
Harry
Colorado
Shenanigans
Mandy
Rusty

View file

@ -0,0 +1,8 @@
data1 = float(input("Enter the dividend "))
data2 = float(input("Enter the divisor "))
quotient = data1/data2
print(f"{data1}/{data2} = {quotient}")

View file

@ -0,0 +1,13 @@
import sys
data1 = float(input("Enter the dividend "))
data2 = float(input("Enter the divisor "))
try:
quotient = data1/data2
print(f"{data1}/{data2} = {quotient}")
except:
print(f"Invalid value. Division by zero is not allowed.")
sys.exit(-1)

View file

@ -0,0 +1,20 @@
import sys
try:
data1 = float(input("Enter the dividend "))
except:
print(f"Invalid value for the dividend ")
sys.exit(-2)
try:
data2 = float(input("Enter the divisor "))
except:
print(f"Invalid value for the divisor ")
sys.exit(-3)
try:
quotient = data1/data2
print(f"{data1}/{data2} = {quotient}")
except:
print(f"Invalid value. Division by zero is not allowed.")
sys.exit(-1)

View file

@ -0,0 +1,19 @@
import sys
def getFloatValue(message):
try:
data1 = float(input(message))
except:
print(f"Invalid value for a floating point number. ")
sys.exit(-2)
return data1
data1 = getFloatValue("Enter value for the dividend ")
data2 = getFloatValue("Enter value for the divisor ")
try:
quotient = data1/data2
print(f"{data1}/{data2} = {quotient}")
except:
print(f"Invalid value. Division by zero is not allowed.")
sys.exit(-1)

View file

@ -0,0 +1,4 @@
# https://www.w3schools.io/file/csv-extension-introduction/