
These interactive web apps I have made as a part of my studies in LAB.
Click images to play! Apps will open in a new tab.
In building this portfolio I have used HTML and SASS/CSS as well as some JavaScript.
This site is the best sample of my current skills. Below you can also see some of the sites I have designed and built in the past.
Click or hover the image to see more.
Here are some examples of programming exercises I have written in the autumn of 2024.
Click to see the code.
"""
File: A7_T6.py
Author: Kaisa Juhola
Date: 2024-11-05
Description: Rock Paper Scissors
"""
import random
random.seed(1234)
# Constants
RPS = ("rock", "paper", "scissors")
BOT = "RPS-3PO"
# Functions
def showMenu() -> None:
print("\nOptions:")
print("1 - Rock")
print("2 - Paper")
print("3 - Scissors")
print("0 - Quit game")
return None
def drawRock() -> None:
print()
print(" _______")
print("---' ____)")
print(" (_____)")
print(" (_____)")
print(" (____)")
print("---.__(___)")
print()
return None
def drawPaper() -> None:
print()
print(" _______")
print("---' ____)____")
print(" ______)")
print(" _______)")
print(" _______)")
print("---.__________)")
print()
def drawScissors() -> None:
print()
print(" _______")
print("---' ____)____")
print(" ______)")
print(" __________)")
print(" (____)")
print("---.__(___)")
print()
return None
def drawResults(Player: str, Bot: str, PPlayerChoice: int, PBotChoice: int) -> None:
print("#########################")
print(f"{Player} chose {RPS[PPlayerChoice - 1]}.")
if PPlayerChoice == 1:
drawRock()
elif PPlayerChoice == 2:
drawPaper()
else:
drawScissors()
print("#########################")
print(f"{Bot} chose {RPS[PBotChoice - 1]}.")
if PBotChoice == 1:
drawRock()
elif PBotChoice == 2:
drawPaper()
else:
drawScissors()
print("#########################")
return None
def playGame(Player: str, Bot: str, PlayerResults: list, BotResults: list) -> None:
while (True):
showMenu()
PChoice = int(input("Your choice: "))
if (PChoice == 0):
break
else:
print("Rock! Paper! Scissors! Shoot!\n")
BChoice = random.randint(1, 3)
if PChoice == BChoice:
PlayerResults[2] += 1
BotResults[2] += 1
Result = f"Draw! Both players chose {RPS[PChoice - 1]}."
else:
if (PChoice == 1 and
BChoice == 2) or (PChoice == 2 and BChoice == 3) or (PChoice == 3 and BChoice == 1):
Winner = Bot
Loser = Player
BotResults[0] += 1
PlayerResults[1] += 1
WinChoice = RPS[BChoice - 1]
LosChoice = RPS[PChoice - 1]
else:
Winner = Player
Loser = Bot
BotResults[1] += 1
PlayerResults[0] += 1
WinChoice = RPS[PChoice - 1]
LosChoice = RPS[BChoice - 1]
Result = f"{Winner} {WinChoice} beats {Loser} {LosChoice}."
drawResults(Player, Bot, PChoice, BChoice)
print()
print(Result)
return None
def showResults(Plr: str, Bot: str, PRes: list, BRes: list) -> None:
print()
print("Results:")
print(f"{Plr} - wins ({PRes[0]}), losses ({PRes[1]}), draws ({PRes[2]})")
print(f"{Bot} - wins ({BRes[0]}), losses ({BRes[1]}), draws ({BRes[2]})")
print()
return None
def main() -> None:
# 1. Initialize
PlayerResults = [0, 0, 0]
OpponentResults = [0, 0, 0]
# 2. Operate
print("Program starting.")
print("Welcome to the rock-paper-scissors game!")
Name = input("Insert player name: ")
print(f"Welcome {Name}!")
print(f"Your opponent is {BOT}.")
print("Game starts...")
playGame(Name, BOT, PlayerResults, OpponentResults)
showResults(Name, BOT, PlayerResults, OpponentResults)
# 3. Cleanup
PlayerResults.clear()
OpponentResults.clear()
print("Program ending.")
return None
main()
"""
File: A6_T7.py
Author: Kaisa Juhola
Date: 2024-10-13
Description: Messages from the Four Emperors
"""
# Constants
FILENAME = "player_progress.txt"
LOWER_ABC = "abcdefghijklmnopqrstuvwxyz"
UPPER_ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
# Functions
def readMessage(PFileName: str) -> str:
# Open FileHandle
FileHandle = open(PFileName, "r", encoding="UTF-8")
# Read FileHandle
Content = FileHandle.readlines()
Content.pop(0)
Message = "".join(Content)
# Close Filehandle
FileHandle.close()
return Message
def cipherText(PText: str) -> str:
CipheredWord = ""
for char in PText:
if char in LOWER_ABC:
CipheredWord += LOWER_ABC[(LOWER_ABC.index(char) + 13) % 26]
elif char in UPPER_ABC:
CipheredWord += UPPER_ABC[(UPPER_ABC.index(char) + 13) % 26]
else:
CipheredWord += char
return CipheredWord
def readFirstLine(PFileName: str) -> str:
# Open FileHandle
FileHandle = open(PFileName, "r", encoding="UTF-8")
# Read FileHandle
Content = FileHandle.readlines()
FirstLine = Content[0].strip()
# Close Filehandle
FileHandle.close()
return FirstLine
def readLastLine(PFileName: str) -> list:
# Open FileHandle
FileHandle = open(PFileName, "r", encoding="UTF-8")
# Read FileHandle
Content = FileHandle.readlines()
LastLine = Content[-1].strip()
if LastLine == "":
LastLine = Content[-2].strip()
# Close Filehandle
FileHandle.close()
LogList = LastLine.split(";")
return LogList
def appendFile(PFileName: str, PEvent: str) -> None:
# 1. Open file handle in append mode
Filehandle = open(PFileName, 'a', encoding="UTF-8")
# 2. Append content
Filehandle.write(PEvent)
# 3. Save changes
Filehandle.close()
return None
def currentLocation(PLogList: list) -> int:
Location = int(PLogList[0])
return Location
def nextLocation(PLogList: list) -> int:
NextLocation = int(PLogList[1])
return NextLocation
def cipPassPhrase(PLogList: list) -> str:
CipPassPhrase = PLogList[2]
return CipPassPhrase
def shoutPassPhrase(PCipPassPhrase: str) -> str:
PassPhrase = cipherText(PCipPassPhrase)
return PassPhrase
def locations(PLocation: int) -> str:
if PLocation == 0:
Location = "home"
elif PLocation == 1:
Location = "Galba's palace"
elif PLocation == 2:
Location = "Otho's palace"
elif PLocation == 3:
Location = "Vitellius' palace"
elif PLocation == 4:
Location = "Vespasian's palace"
else:
Location = "unknown"
return Location
def generateFileName(PLocation: int, PPassPhrase: str) -> str:
FileName = f"{PLocation}-{PPassPhrase}.txt"
return FileName
def generateCipFileName(PLocation: int, PPassPhrase: str) -> str:
CipFileName = f"{PLocation}_{PPassPhrase}.gkg"
return CipFileName
def writeFile(PFileName: str, PContent: str) -> None:
# Open FileHandle
FileHandle = open(PFileName, "w", encoding="UTF-8")
# Write FileHandle
FileHandle.write(PContent)
# Close Filehandle
FileHandle.close()
return None
# Main program definition
def main() -> None:
# 1. Initialize
print("Travel starting.")
# 2. Operate
LogFile = str(FILENAME)
LogList = readLastLine(LogFile)
CurrentLocation = currentLocation(LogList)
Start = locations(CurrentLocation)
print(f"Currently at {Start}.")
NextLocation = nextLocation(LogList)
Next = locations(NextLocation)
print(f"Travelling to {Next}...")
print(f"...Arriving to the {Next}.")
print("Passing the guard at the entrance.")
CipPassPhrase = cipPassPhrase(LogList)
PassPhrase = shoutPassPhrase(CipPassPhrase)
CapitalPassPhrase = PassPhrase.capitalize()
print(f"\"{CapitalPassPhrase}!\"")
print("Looking for the message in the palace...")
CipFileName = generateCipFileName(NextLocation, CipPassPhrase)
FileName = generateFileName(NextLocation, PassPhrase)
print("Ah, there it is! Seems cryptic.")
CipheredMessage = readMessage(CipFileName)
FirstLine = readFirstLine(CipFileName) + "\n"
appendFile(LogFile, FirstLine)
print("[Game] Progress autosaved!")
print("Deciphering Emperor's message...")
Message = cipherText(CipheredMessage)
writeFile(FileName, Message)
print("Looks like I've got now the plain version copy of the Emperor's message.")
print("Time to leave...")
# 3. Cleanup
print("Travel ending.")
return None
main()
# coding: utf-8
begin
print ("Anna luku: ")
luku1=gets.chomp.to_f
print ("Anna luku: ")
luku2=gets.chomp.to_f
jatketaanko = true
while jatketaanko == true
puts ("\nArvot luku1 = #{luku1} ; luku2 = #{luku2}")
puts ("1: + 2: - 3: * 4: / 5: Vaihda luvut 6: Lopeta")
print("Valitse toiminto: ")
toiminto=gets.chomp.to_i
if toiminto == 6
jatketaanko = false
elsif
if toiminto == 1
vastaus=luku1+luku2
elsif toiminto == 2
vastaus=luku1-luku2
elsif toiminto == 3
vastaus=luku1*luku2
elsif toiminto == 4
vastaus=luku1/luku2
end
puts ("Tulos on #{vastaus}.")
elsif toiminto == 5
print ("Anna luku: ")
luku1=gets.chomp.to_f
print ("Anna luku: ")
luku2=gets.chomp.to_f
jatketaanko = true
end
end
rescue ZeroDivisionError
puts ("Taisit yrittää nollalla jakoa?")
rescue
puts("Virheellinen syöte.")
retry
end
# coding: utf-8
def onkopalindromi(merkkijono)
if merkkijono.length <5
puts "#{merkkijono} ei ole kelvollinen sana."
else
oikeinpain=merkkijono.downcase.gsub(" ", "")
vaarinpain=oikeinpain.reverse
if oikeinpain == vaarinpain
puts "#{merkkijono} on palindromi."
else
puts "#{merkkijono} ei ole palindromi; se on väärinpäin #{merkkijono.reverse}."
end
end
end
#kutsutaan metodia
testataanko=true
while testataanko
print "Kirjoita testattava lause: "
testattava=gets.chomp
onkopalindromi(testattava)
print "Testataanko lisää? (k/e): "
vastaus = gets.chomp
if vastaus == "k"
testataanko = true
elsif vastaus =="e"
testataanko = false
else
print "Anna joko k tai e!"
testataanko = true
end
end
fun main(args: Array) {
var list = mutableListOf()
print("Anna lajiteltavien numeroiden lukumäärä :")
var number = readLine()!!.toInt()
for (i in 1..number) {
print("Anna taulukon $i numero :")
var value = readLine()!!.toInt()
list.add(value)
}
val sorted = bubbleSort(list)
println("Lajiteltu lista nousevassa järjestyksessä: $sorted")
}
fun bubbleSort(list: List): List {
var sortedlist = list.toMutableList()
var length: Int = list.size
var swapped: Boolean = true
while (swapped) {
swapped = false
for (i in 1..length-1) {
var a: Int = sortedlist[i - 1]
var b: Int = sortedlist[i]
if (a > b) {
sortedlist[i - 1] = b
sortedlist[i] = a
swapped = true
}
}
}
return sortedlist
}
All jewelry here is designed by me and hand-crafted either by me or my business partner at CaiSanni Jewelry.
Click the image to see it larger. All images will open in a new tab.
Click the image to see it larger. All images will open in a new tab.