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: 5 additions & 0 deletions exercises/ex00_hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""My first program for COMP110."""

__author__ = "730472840"

print("Hello, world.")
68 changes: 68 additions & 0 deletions exercises/ex01_chardle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""EX01 - Chardle - A cute step towards Wordle."""
__author__ = "730472840"

word: str = input("Enter a 5-character word: ")

if len(word) < 5:
print("Error: Word must contain 5 characters")
exit()
if len(word) > 5:
print("Error: Word must contain 5 characters")
exit()

character: str = input("Enter a single character: ")

if len(character) < 1:
print("Error: Character must be a single character.")
exit()

if len(character) > 1:
print("Error: Character must be a single character.")
exit()

print("Searching for " + character + " in " + word)
matching_characters: int = 0

if character == word[0]:
print(character + " found at index 0")
matching_characters = matching_characters + 1

if character == word[1]:
print(character + " found at index 1")
matching_characters = matching_characters + 1

if character == word[2]:
print(character + " found at index 2")
matching_characters = matching_characters + 1

if character == word[3]:
print(character + " found at index 3")
matching_characters = matching_characters + 1

if character == word[4]:
print(character + " found at index 4")
matching_characters = matching_characters + 1


if matching_characters == 1:
print(str(matching_characters) + " instance of " + character + " found in " + word)

if matching_characters == 0:
print("No instances of " + character + " found in " + word)

if matching_characters > 1:
print(str(matching_characters) + " instances of " + character + " found in " + word)














6 changes: 6 additions & 0 deletions lessons/00_stored_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""An example, simple program."""

print("Hello, world")
quiz: int = 100
print(quiz)
print("Goodbye.")
11 changes: 11 additions & 0 deletions lessons/age.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Example memory diagram program"""

age: int = int(input("What is your age? "))
year: int = int(input("What year is it? "))
age_in_2041: int = 2041 - year + age
print("Your age in 2041 will be " + str(age_in_2041))

age = age + 1
year = year + 1
print("In " + str(year) + ", you'll be " + str(age))

18 changes: 18 additions & 0 deletions lessons/conditionals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""An example of conditional (if-else) statements."""

SECRET: int = 3

print("I'm thinking of a number between 1-5, what is it?")
guess: int = int(input("What is your guess? "))

if guess == SECRET:
print("You guessed correctly!!!")
print("Have a wonderful day!!!")
else:
print("Sorry, you guessed incorrectly :(")
if guess > SECRET:
print("You guessed too high!")
else:
print("You guessed too low!")

print("Game over.")
5 changes: 5 additions & 0 deletions lessons/input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Demonstrates asking the user for input"""

user_name: str = input("What is your name? ")
print("Hello, " + user_name + ", good morning!")
print("You are awesome, " + user_name)