Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Git Lab 1
# Pranav Agrawala

**<u> RESOURCES </u>**

Empty file added gitignore
Empty file.
90 changes: 90 additions & 0 deletions program1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import sys

#Checks to see if there is one string
if (len(sys.argv) != 2):
print("ERROR: Provide only one string")
exit(1)

#Checks to see if there is a dot
money = sys.argv[1]
if not ("." in money):
print("ERROR: The string must be in '$X.YZ' format")
exit(1)

split = money.split(".")

#Checks to see if there is a dollar sign
if not ("$" in split[0]):
print("ERROR: The string must start with a $")
exit(1)

#Checks to see if there is a dollar amount
if (len(split[0]) == 1):
print("ERROR: The string must include a dollar amount")
exit(1)

#Checks to see if there is two digits for cents
if (len(split[1]) != 2):
print("ERROR: The string must be in '$X.YZ' format")
exit(1)

dollarString = split[0]
centString = split[1]

#Checks to see if dollar amount is an integer
try:
dollars = int(dollarString[1:])
except:
print("ERROR: Dollars must be an integer")
exit(1)

#Checks to see if cents amount is an integer
try:
cents = int(centString)
except:
print("ERROR: Cents must be an integer")
exit(1)

#Checks if dollar amount is between 0 and 100 inclusive
if (dollars > 100 or dollars < 0):
print("ERROR: Dollars must be between 0 and 100 inclusive")
exit(1)

#Print amount of dollars
if dollars > 1:
print(dollars, "dollars")
if dollars == 1:
print(dollars, "dollar")

#Print amount of quarters
if cents >= 25:
quarters = int(cents/25)
if quarters > 1:
print(quarters, "quarters")
else:
print(quarters, "quarter")
cents %= 25

#Print amount of dimes
if cents >= 10:
dimes = int(cents/10)
if dimes > 1:
print(dimes, "dimes")
else:
print(dimes, "dime")
cents %= 10

#Print amount of nickels
if cents >= 5:
nickels = int(cents/5)
if nickels > 1:
print(nickels, "nickels")
else:
print(nickels, "nickel")
cents %= 5

#Print amount of pennies
if cents > 1:
print(cents, "pennies")
if cents == 1:
print(cents, "penny")
41 changes: 41 additions & 0 deletions program2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//Check if there is at least one string
if (process.argv.length === 2) {
console.error("ERROR: You must provide at least one string")
process.exit(1)
}

//Split, lowercase, and remove punctuation in string
let originalText = process.argv.slice(2)
originalText = originalText.join(' ')
lowerText = originalText.toLowerCase()

const punctuation = ['.', ',', ';', ':', '!', '?', '"', "'", '(', ')', '[', ']', '{', '}', '-', '_', '“', '”'];
let text = '';
for (let i = 0; i < lowerText.length; i++) {
if (!punctuation.includes(lowerText[i])) {
text += lowerText[i];
}
}
text = text.split(' ')

wordCount = {}

//Track frequency of each word
for (let i = 0; i < text.length; i++) {
let word = text[i]
if (word in wordCount){
wordCount[word] ++
}
else {
wordCount[word] = 1
}
}

//Print out words with duplicates
for (let word in wordCount) {
if (wordCount[word] > 1){
let index = lowerText.indexOf(word)
console.log(originalText.slice(index,index+word.length))
}
}

17 changes: 17 additions & 0 deletions program3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<link rel="stylesheet" href="program3.css">
<title>Program 3</title>
</head>

<body>
<form>
<label>Username:</label>
<input type="text"><br>
<label>Password:</label>
<input type="text"><br>
<label>Favourite Color:</label>
<input type="color">
</form>
</body>
</html>