diff --git a/exercises/ex00_hello_world.py b/exercises/ex00_hello_world.py new file mode 100644 index 00000000..a6cac79e --- /dev/null +++ b/exercises/ex00_hello_world.py @@ -0,0 +1,8 @@ +"""My First Program for COMP 110""" + + +__author__="730473073" + +print("Hello, world.") + +print("I want to learn more about COMP 110, OXOX, hehe") diff --git a/exercises/ex01_chardle.py b/exercises/ex01_chardle.py new file mode 100644 index 00000000..f0ed1305 --- /dev/null +++ b/exercises/ex01_chardle.py @@ -0,0 +1,41 @@ +"""Ex01 - Chardle- a cute step toward Wordle.""" + +__author__= "730473073" + + + +word: str=input("Enter a 5-character word:") +if len(word) !=5: + print("Error: Word must have 5 characters") + exit() +Letter: str=input("Enter a single character:") +if len(Letter)!=1: + print("Error: Character must be a single character") + exit() + +print("Searching for " + Letter + " in " +word) + +amount= 0 +if Letter== word[0]: + print(Letter +" found at index 0") + amount+=1 +if Letter== word[1]: + print(Letter +" found at index 1") + amount+=1 +if Letter== word[2]: + print(Letter +" found at index 2") + amount+=1 +if Letter== word[3]: + print(Letter +" found at index 3") + amount+=1 +if Letter== word[4]: + print(Letter +" found at index 4") + amount+=1 +if amount>0: + if amount==1: + print("1 instance of " + Letter + " found in "+ word) + else: + print(str(amount)+ " instances of "+ Letter + " found in " + word) +else: + print(" No instances of "+ Letter + " found in "+ word) +