From 8098728b2e73fface1b9733411dcc616199658e6 Mon Sep 17 00:00:00 2001 From: Ram Basnet Date: Fri, 27 Sep 2024 08:53:16 -0600 Subject: [PATCH] moved labs to its own GitHub repo --- labs/README.md | 7 ++ labs/conditionals/twostones/README.md | 51 --------- labs/conditionals/twostones/main.py | 58 ---------- labs/conditionals/twostones/test_main.py | 29 ----- labs/dicts/morsecodepalindromes/README.md | 51 --------- labs/dicts/morsecodepalindromes/morsecode.py | 101 ----------------- .../morsecodepalindromes/test_morsecode.py | 20 ---- labs/fileio/README.md | 42 ------- labs/fileio/data.in | 10 -- labs/fileio/file_io.py | 96 ---------------- labs/fileio/test_file_io.py | 21 ---- labs/functions/buka/README.md | 42 ------- labs/functions/buka/main.py | 40 ------- labs/functions/lastproblem/README.md | 52 --------- labs/functions/lastproblem/main.py | 52 --------- labs/functions/lastproblem/test_main.py | 27 ----- labs/guessing_game/README.md | 42 ------- labs/guessing_game/game.py | 71 ------------ labs/guessing_game/main.py | 76 ------------- labs/guessing_game/settings.py | 14 --- labs/guessing_game/tests/__init__.py | 0 labs/guessing_game/tests/test_functions.py | 47 -------- labs/guessing_game/utility/__init__.py | 0 labs/guessing_game/utility/functions.py | 107 ------------------ labs/lists/pet/1.ans | 1 - labs/lists/pet/1.in | 5 - labs/lists/pet/2.ans | 1 - labs/lists/pet/2.in | 5 - labs/lists/pet/README.md | 50 -------- labs/lists/pet/pet.py | 75 ------------ labs/lists/pet/test_pet.py | 38 ------- labs/loops/oddities/README.md | 51 --------- labs/loops/oddities/oddities.py | 69 ----------- labs/loops/oddities/test_oddities.py | 42 ------- labs/math/addtwonumbers/README.md | 43 ------- labs/math/addtwonumbers/main.py | 35 ------ labs/oop/README.md | 88 -------------- labs/oop/bijele/bijele.py | 30 ----- labs/oop/bijele/chess.py | 26 ----- labs/oop/bijele/test_chess.py | 42 ------- labs/stdio/ascii/README.md | 56 --------- labs/stdio/ascii/main.py | 40 ------- labs/strings/simonsays/README.md | 50 -------- labs/strings/simonsays/simonsays.py | 62 ---------- labs/strings/simonsays/test_simonsays.py | 35 ------ labs/unittest/README.md | 91 --------------- 46 files changed, 7 insertions(+), 1984 deletions(-) create mode 100644 labs/README.md delete mode 100644 labs/conditionals/twostones/README.md delete mode 100644 labs/conditionals/twostones/main.py delete mode 100644 labs/conditionals/twostones/test_main.py delete mode 100644 labs/dicts/morsecodepalindromes/README.md delete mode 100644 labs/dicts/morsecodepalindromes/morsecode.py delete mode 100644 labs/dicts/morsecodepalindromes/test_morsecode.py delete mode 100644 labs/fileio/README.md delete mode 100644 labs/fileio/data.in delete mode 100644 labs/fileio/file_io.py delete mode 100644 labs/fileio/test_file_io.py delete mode 100644 labs/functions/buka/README.md delete mode 100644 labs/functions/buka/main.py delete mode 100644 labs/functions/lastproblem/README.md delete mode 100644 labs/functions/lastproblem/main.py delete mode 100644 labs/functions/lastproblem/test_main.py delete mode 100644 labs/guessing_game/README.md delete mode 100644 labs/guessing_game/game.py delete mode 100644 labs/guessing_game/main.py delete mode 100644 labs/guessing_game/settings.py delete mode 100644 labs/guessing_game/tests/__init__.py delete mode 100644 labs/guessing_game/tests/test_functions.py delete mode 100644 labs/guessing_game/utility/__init__.py delete mode 100644 labs/guessing_game/utility/functions.py delete mode 100644 labs/lists/pet/1.ans delete mode 100644 labs/lists/pet/1.in delete mode 100644 labs/lists/pet/2.ans delete mode 100644 labs/lists/pet/2.in delete mode 100644 labs/lists/pet/README.md delete mode 100644 labs/lists/pet/pet.py delete mode 100644 labs/lists/pet/test_pet.py delete mode 100644 labs/loops/oddities/README.md delete mode 100644 labs/loops/oddities/oddities.py delete mode 100644 labs/loops/oddities/test_oddities.py delete mode 100644 labs/math/addtwonumbers/README.md delete mode 100644 labs/math/addtwonumbers/main.py delete mode 100644 labs/oop/README.md delete mode 100644 labs/oop/bijele/bijele.py delete mode 100644 labs/oop/bijele/chess.py delete mode 100644 labs/oop/bijele/test_chess.py delete mode 100644 labs/stdio/ascii/README.md delete mode 100644 labs/stdio/ascii/main.py delete mode 100644 labs/strings/simonsays/README.md delete mode 100644 labs/strings/simonsays/simonsays.py delete mode 100644 labs/strings/simonsays/test_simonsays.py delete mode 100644 labs/unittest/README.md diff --git a/labs/README.md b/labs/README.md new file mode 100644 index 0000000..249c601 --- /dev/null +++ b/labs/README.md @@ -0,0 +1,7 @@ +# Python Fundamental Labs + +- labs have been moved to its own repository at: [https://github.com/rambasnet/Python-Fundamentals-Lab](https://github.com/rambasnet/Python-Fundamentals-Lab) +- separating should make it easier to work GitHub Classroom +- see readonly_labs which is supposed to readonly for students +- they can create their own `labs` folder in the repo and work on each lab +- having a copy gives should a good reference in case they accidently change part of the code they're not supposed to! diff --git a/labs/conditionals/twostones/README.md b/labs/conditionals/twostones/README.md deleted file mode 100644 index 101f13c..0000000 --- a/labs/conditionals/twostones/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# CS0 Lab - Conditionals and Unit testing - -Possible Points: 100 - -Write a Python program to solve the Kattis problem called twostones [https://open.kattis.com/problems/twostones](https://open.kattis.com/problems/twostones). Read the problem statement carefully to design a correct solution. - -## Lab Instructions - -- Open your CS0Lab-... repo in VS Code -- Create lab folder **twostones** inside your CS0Lab-... repository -- Inside the lab folder, create two files: main.py and test_main.py -- Type the partial code stub provided in main.py and test_main.py files and fix all FIXMEs. (80 points) -- Follow best programming practices by using proper white spaces, comments, etc. - -```note -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -- Run unit test using pytest and create screenshot when all the test cases pass. Install pytest if required. Pick one of the following ways to run pytest. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest test_main.py - $ python -m pytest test_main.py -``` - -- Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -- Upload only the solution script to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -- Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -- Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo. diff --git a/labs/conditionals/twostones/main.py b/labs/conditionals/twostones/main.py deleted file mode 100644 index b283b10..0000000 --- a/labs/conditionals/twostones/main.py +++ /dev/null @@ -1,58 +0,0 @@ -""" -Conditional Logic Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve the Kattis problem: https://open.kattis.com/problems/twostones - -Algorithm Steps: - 1. Read the number of stones - 2. Check if the number of stones is odd or even - 3. Print the winner - 3.a. If the number is odd, Alice wins. - 3.b. Otherwise, Bob wins. -""" - - -def main(): - """Main function that solves the problem - """ - # FIXME 1: read the number of stones - # FIXME 2: call answer function passing the number of stones as an argument - # FIXME 3: print the answer as shown in the sample output - - -def odd_even(number: int): - """Checks if the number is odd or even - - Args: - number (int): number to check odd or even - - Returns: - str: 'odd' if the number is odd, 'even' otherwise - """ - # FIXME 4: if the number divided by 2 has 0 remainder, return 'even' - # otherwise, return 'odd' - ans = "FIXME" - return ans - - -def answer(stone: int): - """Creates the final answer and returns it given the number of stones - - Args: - stone (int): number of stones - - Returns: - str: 'Alice' if the number of stones is odd, 'Bob' otherwise - """ - evenorodd = odd_even(stone) - if evenorodd == "odd": - return "Alice" - else: - return "Bob" - - -if __name__ == "__main__": - main() diff --git a/labs/conditionals/twostones/test_main.py b/labs/conditionals/twostones/test_main.py deleted file mode 100644 index 35b7308..0000000 --- a/labs/conditionals/twostones/test_main.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Module to test important functions in main.py -""" - -import main - -# test function must start with test_ prefix for pytest to recognize it - - -def test_odd_even(): - """Function to test odd_even function - """ - number = 99999 - expected = "odd" - ans = main.odd_even(number) - assert (main.odd_even(number) == - ans), f"Expected: {expected}, but got: {ans}" - - -def test_odd_even2(): - """Function to test odd_even function""" - assert (main.odd_even(200) == - "even"), f"Expected: even, but got: {main.odd_even(200)}" - - -# FIXME 5: Write 3rd test case -# FIXME 6: Write 4th test case - - -# FIXME 7: Write 3 test functions to test answer function diff --git a/labs/dicts/morsecodepalindromes/README.md b/labs/dicts/morsecodepalindromes/README.md deleted file mode 100644 index ed8fe81..0000000 --- a/labs/dicts/morsecodepalindromes/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# CS0 Lab - Dictionary and Unit testing - -Possible Points: 100 - -Write a Python program to solve the Kattis problem Morse Code Palindrome: [https://open.kattis.com/problems/morsecodepalindromes](https://open.kattis.com/problems/morsecodepalindromes). Read the problem statement carefully to design a correct solution. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create a lab folder **dicts** inside your CS0Lab-... repository -3. Inside the lab folder, create two files morsecode.py and test_morsecode.py. -4. Type the partial code stub provided and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -```text -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Unittest all the important functions using pytest. Install pytest if required. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest test_main.py - $ python -m pytest test_main.py -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the solution script to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -10. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo. diff --git a/labs/dicts/morsecodepalindromes/morsecode.py b/labs/dicts/morsecodepalindromes/morsecode.py deleted file mode 100644 index 867d256..0000000 --- a/labs/dicts/morsecodepalindromes/morsecode.py +++ /dev/null @@ -1,101 +0,0 @@ -""" -Dictionary and Unittest Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Solution for Kattis problem - Morse Code Palindromes - https://open.kattis.com/problems/morsecodepalindromes - -Given english text, the program finds if the corresponding morse code is a palindrome. - -Algorithm steps: -1. Create a dictionary to map alphabets and numbers to morse code -2. Read the input english string -3. Convert the string into upper case english string -4. Convert english string into Morse Code string using the dictionary -5. Check if the Morse Code string is a palindrome - i. Print 1 if it's a palindrome - ii Otherwise, print 0 -""" -import sys - -# create English to Morse Code dictionary -engToMorse = { - 'A': '.-', - 'B': '-...', - 'C': '-.-.', - 'D': '-..', - 'E': '.', - 'F': '..-.', - 'G': '--.', - 'H': '....', - 'I': '..', - 'J': '.---', - 'K': '-.-', - 'L': '.-..', - 'M': '--', - 'N': '-.', - 'O': '---', - 'P': '.--.', - 'Q': '--.-', - 'R': '.-.', - 'S': '...', - 'T': '-', - 'U': '..-', - 'V': '...-', - 'W': '.--', - 'X': '-..-', - 'Y': '-.--', - 'Z': '--..', - # FIXME 1: map the digits to their corresponding morse code -} - - -def is_palindrome(morse_code: str) -> int: - """Returns 1 if the morse_code string is palindrome; 0 Otherwise. - - Args: - morse_code (str): morse code palindrome string - - Returns: - int: 1 or 0 - """ - # FIXME 2: if the morse_code string is empty, return 0 - # Otherwise use the algorithm: - # 1. reverse the morse_code string and store into a variable - # 2. if the morse_code equals to the reversed string, it is a palindrome and return 1 - # 3. return 0 otherwise - return 1 - - -def convert_to_morse(english: str) -> str: - """The function converts the given english text into corresponding morese code - - Args: - english (str): eglish text convereted into upper case - - Returns: - str: Morse code - """ - morse_code = '' - # Algorithm steps: - # For ecah character in english, - # find the morse code of the character using engToMorse dictionary - # concatenate morse code to morse_code variable if key exists - # ignore the key/character if it doesn't exist in the dictionary - # FIXME 3: implement the above algorithm - return morse_code - - -def solve() -> None: - # read/input english text as a line - english = input() - # FIXME 4: convert english into uppercase - upper_english = english - print(upper_english, file=sys.stderr) - morse_code = convert_to_morse(upper_english) - # FIXME 5: call is_palindrome passing proper argument and print the result - - -if __name__ == '__main__': - solve() diff --git a/labs/dicts/morsecodepalindromes/test_morsecode.py b/labs/dicts/morsecodepalindromes/test_morsecode.py deleted file mode 100644 index e72fc1d..0000000 --- a/labs/dicts/morsecodepalindromes/test_morsecode.py +++ /dev/null @@ -1,20 +0,0 @@ -"""Module to test functions in morsecode.py -""" - -import morsecode - - -def test_convert_to_palindrome1(): - actual_ans = morsecode.convert_to_morse('AN') - expected_ans = '.--.' - assert actual_ans == expected_ans - -# FIXME 6 - write 3 more test cases to test convert_to_palindrome function - - -def test_ispalindrome1(): - ans = morsecode.is_palindrome('.--.') - expected = 1 - assert ans == expected - -# FIXME 7 - Write 3 more test cases to test is_palindrome function diff --git a/labs/fileio/README.md b/labs/fileio/README.md deleted file mode 100644 index 6bff258..0000000 --- a/labs/fileio/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# CS0 Lab - File IO and Unit testing - -Possible Points: 100 - -Python lab to explore working with files. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create a lab folder **fileio** inside your CS0Lab-... repository -3. Inside the lab folder, create three files: file_io.py, test_file_io.py, and data.in - - Copy data.in contents into data.in file. -4. Type the partial code stub provided and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. -6. Unittest all the important functions using pytest. Install pytest if required. - -```bash -$ pytest --version -$ pip install -U pytest -$ pytest test_*.py -$ python -m pytest test_*.py -``` - -7. Test the whole program manually. -8. Create screenshots showing your local test results (pytest and manual test of main script) and save them to the lab folder. (20 points) -9. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/fileio/data.in b/labs/fileio/data.in deleted file mode 100644 index 1417450..0000000 --- a/labs/fileio/data.in +++ /dev/null @@ -1,10 +0,0 @@ -10 -5 -100 -99 -101 -89 -99 -37 -43 -123 diff --git a/labs/fileio/file_io.py b/labs/fileio/file_io.py deleted file mode 100644 index 9ef6c2e..0000000 --- a/labs/fileio/file_io.py +++ /dev/null @@ -1,96 +0,0 @@ -""" -File I/O Lab -By: FIXME0 - -CSCI 110 -Date: FIXME0 - -Program prompts user to enter name of the file that contains 10 integers. -It opens, reads and stores the numbers into a list. -Program will then sort the numbers in the list in ascending and descending orders -Program will then print the sorted lists to an output file along with the -largest and smallest values in the list. - -NOTE: All fixme's are each worth 10 points except for the FIXME1 which is worth 20 points -""" - -from typing import List - -totalInts = 10 - - -def readData() -> List[int]: - """Read data from a file. - - Returns: - List[int]: List of integers - """ - intList = [] - # FIXME1 (20 points): - # Prompt user to input file name - # open the file; read each number one line at a time; - # and store it into intList list - # close the file - # return the intList - return intList - - -def sortListInAscendingOrder(lstInts: List[int]): - """Sort the provided list in ascending order. - - Args: - lstInts (List[int]): the list to be sorted. - """ - # FIXME2 - # sort lstInts list in ascending order - - -def sortListInDescendingOrder(lstInts: List[int]): - """Sort the provided list in descending order. - - Args: - lstInts (List[int]): the list to be sorted. - """ - # FIXME3 - # sort lstInts in descending order - - -def printList(printFile, lstInts: List[int]): - for n in lstInts: - # FIXME4 - # write each value one line at a time to file - # handled by printFile object. - pass - printFile.write('\n') - - -def main(): - integers = [] # list to store integers - integers = readData() - outputFileName = input('Enter a file to write output to: ') - printFile = open(outputFileName, 'w') - printFile.write("Numbers entered:\n") - printList(printFile, integers) - # sort numbers - sortListInAscendingOrder(integers) - printFile.write("Numbers sorted in ascending order:\n") - printList(printFile, integers) - - # FIXME5 - # Call sortListInDescendingOrder function - - # FIXME6 - # Write the sorted list in descending order to the output file - - # FIXME7 - # Print the largest number to the output file - - # FIXME8 - # Print the smallest number to the output file - - printFile.close() - print('Done executing the program! Check the output file for results.') - - -# FIXME9 -# Call main function if this module is run as the main module diff --git a/labs/fileio/test_file_io.py b/labs/fileio/test_file_io.py deleted file mode 100644 index 60461f5..0000000 --- a/labs/fileio/test_file_io.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Modue to test file_io.py -""" - -import file_io - - -def test_sort_ascending1(): - my_nums = [10, 9, 0. - 6] - file_io.sortListInAscendingOrder(my_nums) - assert (my_nums == [-6, 0, 9, 10]) - -# add 3 more test cases in separate test functions - - -def test_sort_descending1(): - my_nums = [0, -10, -1, 5, 100] - file_io.sortListInDescendingOrder(my_nums) - my_nums == [100, 5, 0, -1, -10] - - -# add 3 more test cases in seeparate test functions diff --git a/labs/functions/buka/README.md b/labs/functions/buka/README.md deleted file mode 100644 index 2b8a070..0000000 --- a/labs/functions/buka/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# CS0 Lab - Built-in and Library Functions - -Possible Points: 100 - -Write a Python program to solve the Kattis problem called buka: [https://open.kattis.com/problems/buka](https://open.kattis.com/problems/buka). Read the problem statement carefully to design a correct solution. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create lab folder **buka** inside your CS0Lab-... repository -3. Inside the lab folder, create a file: main.py -4. Use the partial code stub provided in main.py file and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -``` -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the .py scripts to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -10. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/functions/buka/main.py b/labs/functions/buka/main.py deleted file mode 100644 index 495a29f..0000000 --- a/labs/functions/buka/main.py +++ /dev/null @@ -1,40 +0,0 @@ -""" -Built-in and Library Functions Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Solution to Kattis problem - Buka: https://open.kattis.com/problems/buka - -Algorithm steps: - 1. read the first line or 1st operand into a variable - 3. read the 2nd line or operator into a variable - 3. read the 3rd line or 2nd operand into a variable - 4. concatenate the varialbes into a single string - 5. use the built-in eval function on the concatenated string - 6. print the result of the eval as the answer -""" - -import sys - -# define a main function - - -def main(): - """Main function that solves the problem - """ - # read/input the first operand into A variable using sys library's readline() method - A = sys.stdin.readline().strip() - # let's check the value read... - print(f'{A=}', file=sys.stderr) - # FIXME3 - using sys library, read/input the 2nd line into operator variable - # FIXME4 - using sys library, read/input the 2nd operand into B variable - # FIXME5 - concatenate all three variables into a single variable called equation - # call eval(equation) and assign the return value or result into ans variable - ans = 'FIXME' # FIXME6 - find the answer using eval function - # print the answer using sys library's stdout.write() method - sys.stdout.write(f'{ans}\n') - - -# call main() funtion to execute it -main() diff --git a/labs/functions/lastproblem/README.md b/labs/functions/lastproblem/README.md deleted file mode 100644 index 568e092..0000000 --- a/labs/functions/lastproblem/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# CS0 Lab - User-defined Functions and Unittest - -Possible Points: 100 - -Write a Python program to solve the Kattis problem called thelastproblem: [https://open.kattis.com/problems/thelastproblem](https://open.kattis.com/problems/thelastproblem). Read the problem statement carefully to design a correct solution. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code. -2. Create lab folder called **lastproblem** inside your repository. -3. Inside the the lab folder, create two files: main.py and test_main.py. -4. Use the partial code stub provided and fix all the FIXMEs. (80 points) - - Write #fixed after each fixme that you fix. -5. Follow best programming practices by using proper white spaces, comments, etc. - -``` -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Run unit test using pytest and create screenshot when all the test cases pass. Install pytest if required. Pick one of the following ways to run pytest. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest test_main.py - $ python -m pytest test_main.py -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the .py scripts to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accepted verdict and save them to the lab folder. (10 points) -10. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/functions/lastproblem/main.py b/labs/functions/lastproblem/main.py deleted file mode 100644 index 5d659ce..0000000 --- a/labs/functions/lastproblem/main.py +++ /dev/null @@ -1,52 +0,0 @@ -""" -User-defined functions and Unittest Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve - The Last Problem: https://open.kattis.com/problems/thelastproblem - -Algorithm: -1. Read the input string using function -3. Create the output as asked and print it using function -3. Test functions using test cases -""" - -import sys - - -def main(): - """Main function that solves the problem. - """ - data = read_data() - # FIXME 1: Call answer function passing data as an argument - # store the returned result into ans variable - ans = "FIXME" - # FIXME 2: print the result - - -def read_data() -> str: - """Reads the twilight data from std input and returns it. - Returns: - str: data read from std input - """ - # FIXME 3: read and store the input line into data variable - # FIXME 4: return data - pass - - -def answer(data: str) -> str: - """Creates the twilight output and returns it. - Args: - data (str): name of the person - Returns: - str: twilight output - """ - # FIXME 5: create the output as asked and store it into ans variable - ans = "FIXME" - return ans - - -if __name__ == "__main__": - # FIXME 10: call main function - pass diff --git a/labs/functions/lastproblem/test_main.py b/labs/functions/lastproblem/test_main.py deleted file mode 100644 index b985b47..0000000 --- a/labs/functions/lastproblem/test_main.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Module to test functions from main.py -""" - -import sys -import main - -# test function must start with test_ prefix for pytest to recognize it - - -def test_answer(): - """Test answer function - """ - ans = main.answer("Alice") - expected = "Thank you, Alice, and farewell!" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - ans = main.answer("Bob") - expected = "Thank you, Bob and farewell!" # FIXME 5: fix the expected output - assert ans == expected, f"Expected: {expected}, but got: {ans}" - # FIXME 6: add a new test case to test your answer function - # FIXME 7: add a new test case to test your answer function - # FIXME 8: add a new test case to test your answer function - # FIXME 9: add a new test case to test your answer function - print("All test cases passed...", file=sys.stderr) - - -if __name__ == "__main__": - test_answer() diff --git a/labs/guessing_game/README.md b/labs/guessing_game/README.md deleted file mode 100644 index 85905b0..0000000 --- a/labs/guessing_game/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# CS0 Lab - Game and Unit testing - -Possible Points: 100 - -Python lab to explore working with YAML files. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create a lab folder **guessing_game** inside your CS0Lab-... repository -3. Inside the lab folder, create the project folder structre similar to this lab folder. -4. Type the partial code stub provided and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. -6. Unittest all the important functions using pytest. Install pyyaml and pytest if required. - -```bash -$ pip install pyyaml -$ pytest --version -$ pip install -U pytest -$ pytest test_*.py -$ python -m pytest test_*.py -``` - -7. Test the whole program manually. -8. Create screenshots showing your local test results (pytest and manual test of main script) and save them to the lab folder. (20 points) -9. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/guessing_game/game.py b/labs/guessing_game/game.py deleted file mode 100644 index c11e7d2..0000000 --- a/labs/guessing_game/game.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -Functions related to game main logic. -""" - -from utility import functions - - -def play_game(name: str, max_tries: int) -> bool: - """Main game logic of the Guess The Number game. - - Args: - name (str): name of the player. - max_tries (int): maximum number of tries. - - Returns: - bool: True if the player wins, False otherwise. - """ - print(f"Let's play the Game, {name}! Good luck...") - rand = functions.get_random_number() - print('I am thinking of a number between 1 and 20.') - print('You have 5 chances to guess the number.') - tries = 0 - while tries <= max_tries: - # FIXME: Add code to get the user's guess using the correct - # function in utility/functions.py. - # FIXME: check if the user's guess is correct using the correct - # function in utility/functions.py. - # FIXME: If the user's guess is correct, print a message and return True for a win. - # FIXME: If the user's guess is incorrect, - # print a message saying their guess is too large or too small - # and increment the number of tries. - return True - else: - return False # return False for a loss - - -def clear_screen() -> None: - """Clears the screen. - """ - print("\033c", end="") - - -def pause() -> None: - """Pauses the screen. - """ - input("Press Enter to continue...") - clear_screen() - - -def get_menu_option() -> int: - """Prints menu for player to interact with. - """ - - menu = """ - Menu Options - ============ - 1. Play Game - 2. View Scoreboard - 3. Quit - """ - print(menu) - while True: - option = input("Enter one of the menu options [1-3]: ") - if not option.isdigit(): - print("Invalid option. Try again.") - continue - int_option = int(option) - if not 1 <= int_option <= 3: - print("Invalid option. Try again.") - continue - return int_option diff --git a/labs/guessing_game/main.py b/labs/guessing_game/main.py deleted file mode 100644 index 59f9d31..0000000 --- a/labs/guessing_game/main.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -Game Application - Guess the Number -""" - -__author__ = "FIXME" -__date__ = "FIXME" -__license__ = "MIT" -__course__ = "CSCI 110 Lab" -__semester__ = "Fall 2023" - -from typing import Any, List, Dict -import time -from utility import functions -import settings -from game import play_game, clear_screen, pause, get_menu_option - - -def game_intro() -> None: - clear_screen() - print('Welcome to the game...') - time.sleep(1) - print(settings.ASCII) - time.sleep(1) - print("Let's start by entering your name.") - print('Are you ready?') - pause() - - -def main() -> None: - """ - Main function for the game. - """ - game_intro() - data = functions.read_data(settings.SCORE_BOARD_FILE) - if not data: - data = [] - - # Ask who's playing? - player = functions.get_player_info() - p = functions.find_player_in_db(data, player['name']) - if p is None: - data.append(player) - else: - player = p - - while True: - clear_screen() - option = get_menu_option() - if option == 1: - win = play_game(player['name'], settings.MAX_TRIES) - if win: - player['win'] += 1 - else: - player['loss'] += 1 - elif option == 2: - view_scoreboard(data) - elif option == 3: - functions.save_data(settings.SCORE_BOARD_FILE, data) - print( - f'saving score board to the file {settings.SCORE_BOARD_FILE}') - print("Goodbye!") - input('Enter to exit...') - break - - -def view_scoreboard(data: List[Any]) -> None: - """Display data in tabular format. - - Args: - data (dict): data of all the players in the database - """ - # FIXME - print data in tabular format - - -if __name__ == "__main__": - main() diff --git a/labs/guessing_game/settings.py b/labs/guessing_game/settings.py deleted file mode 100644 index f393027..0000000 --- a/labs/guessing_game/settings.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -Global Settings for the Guess The Number game. -ASCII Art generated from https://patorjk.com/software/taag/ -""" - -MAX_TRIES = 5 -SCORE_BOARD_FILE = "scoreboard.yaml" -ASCII = """ - GGG TTTTTTh N N b -G TT h NN N b -G GGu ueeesss TT hhh eee N N Nu ummmm bbb eeerrr -G Gu ue ess TT h he e N NNu um m mb be er - GGG uuueesss TT h hee N N uuum m mbbb ee r -""" diff --git a/labs/guessing_game/tests/__init__.py b/labs/guessing_game/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/labs/guessing_game/tests/test_functions.py b/labs/guessing_game/tests/test_functions.py deleted file mode 100644 index 39394ab..0000000 --- a/labs/guessing_game/tests/test_functions.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -Module to test functions.py. -""" - -from utility import functions - - -def test_save_data() -> None: - """Tests save_data function. - """ - data = {"name": "John Smith", "win": 2, "loss": 1} - file_name = "test_data.yaml" - functions.save_data(file_name, data) - my_data = functions.read_data(file_name) - assert data == my_data - - -def test_save_data1() -> None: - """Tests save_data function. - """ - file_name = "test_data1.yaml" - data = [{"name": "John Smith", "win": 2, "loss": 1}, - {"name": "Jake Smith", "win": 1, "loss": 0}] - functions.save_data(file_name, data) - my_data = functions.read_data(file_name) - assert data == my_data - - -# FIXME1: Add a test function to unittest the save_data and read_data functions. -# FIXME2: Add a test function to unittest the save_data and read_data functions. - - -def test_get_random_number() -> None: - """Tests get_random_number function. - """ - random_number = functions.get_random_number() - assert random_number >= 1 and random_number <= 20 - - -def test_check_guessed() -> None: - """Tests check_guessed function. - """ - assert functions.check_guessed(5, 5) == True - - -# FIXME3: Add a test function to unittest the check_guessed function. -# FIXME4: Add a test function to unittest the check_guessed function. diff --git a/labs/guessing_game/utility/__init__.py b/labs/guessing_game/utility/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/labs/guessing_game/utility/functions.py b/labs/guessing_game/utility/functions.py deleted file mode 100644 index 2e6f67f..0000000 --- a/labs/guessing_game/utility/functions.py +++ /dev/null @@ -1,107 +0,0 @@ -""" -Module for utility functions to support the game. -""" - -from typing import Any -import random -import yaml - - -def get_random_number() -> int: - """ - Returns a random integer between 1 and 20, inclusive. - - Returns: - int: integer between 1 and 20, inclusive. - """ - return random.randint(1, 20) - - -def read_data(yaml_file_path: str) -> list: - """ - Reads data from the given file path and returns a dictionary. - - Args: - file_path (str): path to the file to read. - - Returns: - dict: dictionary containing the data read from the file. - """ - data = [] - try: - with open(yaml_file_path, 'r', encoding='utf-8') as file: - data = yaml.safe_load(file) - except FileNotFoundError: - pass - return data - - -def save_data(yaml_file_path: str, data: Any) -> None: - """ - Writes data to the given file path. - - Args: - file_path (str): path to the file to write to. - data (dict): data to write to the file. - """ - with open(yaml_file_path, 'w', encoding='utf-8') as file: - yaml.dump(data, file) - - -def check_guessed(rand: int, guess: int) -> bool: - """ - Checks if the guessed number is correct. - - Args: - rand (int): the random number that is hidden. - guess (int): the user's guessed number. - - Returns: - bool: True if the guessed number is correct, False otherwise. - """ - return rand == guess - - -def get_player_info() -> dict: - """ - Gets new player's info. - - Returns: - dict: new player's info as dict. - """ - name = input("What is your name? ") - return {'name': name.strip(), 'win': 0, 'loss': 0} - - -def get_number_between_1_20() -> int: - """ - Gets a number between 1 and 20, inclusive. - - Returns: - int: number between 1 and 20, inclusive. - """ - while True: - guess = input("Enter your guess: ") - if not guess.isdigit(): - print("Invalid guess. Try again.") - continue - int_guess = int(guess) - # FIXME: Add code to check if the guess is between 1 and 20, inclusive. - # if not a valid number print error and ask them to try again - return int_guess - - -def find_player_in_db(database: list[Any], name: str) -> Any: - """Find and return the player in the database. - - Args: - database (list[Any]): database of players. - name (str): player's name to search for. - - Returns: - None|dict: Returns player as dict if found, None otherwise. - """ - for player in database: - if player['name'] == name: - return player - return None diff --git a/labs/lists/pet/1.ans b/labs/lists/pet/1.ans deleted file mode 100644 index e6e765b..0000000 --- a/labs/lists/pet/1.ans +++ /dev/null @@ -1 +0,0 @@ -4 19 diff --git a/labs/lists/pet/1.in b/labs/lists/pet/1.in deleted file mode 100644 index d09890e..0000000 --- a/labs/lists/pet/1.in +++ /dev/null @@ -1,5 +0,0 @@ -5 4 4 5 -5 4 4 4 -5 5 4 4 -5 5 5 4 -4 4 4 5 diff --git a/labs/lists/pet/2.ans b/labs/lists/pet/2.ans deleted file mode 100644 index f7e771a..0000000 --- a/labs/lists/pet/2.ans +++ /dev/null @@ -1 +0,0 @@ -2 17 diff --git a/labs/lists/pet/2.in b/labs/lists/pet/2.in deleted file mode 100644 index 076b81d..0000000 --- a/labs/lists/pet/2.in +++ /dev/null @@ -1,5 +0,0 @@ -4 4 3 3 -5 4 3 5 -5 5 2 4 -5 5 5 1 -4 4 4 4 diff --git a/labs/lists/pet/README.md b/labs/lists/pet/README.md deleted file mode 100644 index 80fde63..0000000 --- a/labs/lists/pet/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# CS0 Lab - Lists and Unit testing - -Possible Points: 100 - -Write a Python program to solve the Kattis problem called pet: [https://open.kattis.com/problems/pet](https://open.kattis.com/problems/pet). Read the problem statement carefully to design a correct solution. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create lab folder **lists** inside your CS0Lab-... repository -3. Inside the lab folder, create two files: pet.py and test_pet.py -4. Type the partial code stub provided in the lab folder and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -```text -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Unittest all the important functions using pytest. Install pytest if required. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest . - $ python -m pytest . -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the solution script to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -10. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo. diff --git a/labs/lists/pet/pet.py b/labs/lists/pet/pet.py deleted file mode 100644 index 2af2f4a..0000000 --- a/labs/lists/pet/pet.py +++ /dev/null @@ -1,75 +0,0 @@ -""" -Lists and Unittest Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve - Pet: https://open.kattis.com/problems/pet - -Algorithm steps: - 1. Create a list to store the total scores of each contestant - 2. Repeat 5 times: - i. Read the input line - ii. Split the line into a list of numbers - iii. Convert the list of strings into a list of ints - iv. Sum the list of ints - v. Append the sum to the list of scores - 3. Find the max score in the list of scores - 4. Find the index of the max score in the list of scores - 5. Print the index of the max score + 1 and the max score -""" - - -from typing import List - - -def main() -> None: - """Main function that solves the problem - """ - # step 1. create a list to store the total scores of each contestant - scores = [] - # FIXME 1 - repeat step 2-4 5 times - # FIXME 2 - read the input line as a list of integers using get_data function - # FIXME 3 - find the sum of scores using list_sum function - # FIXME 4 - append the sum to the list of scores - # FIXME 5 - print the final output calling answer function - - -def get_data() -> List[int]: - """Reads the data from std input and returns it as a list of ints - Args: - None - Returns: - List[int]: list of ints - """ - str_nums = input().split() # list of string numbers - # FIXME 6: convert str_nums as list of ints and return it - - -def list_sum(numbers: List[int]) -> int: - """Finds and returns sum of the numbers in the list. - Args: - numbers: List[int]: # takes a list of numbers as a parameter - - Returns: - int: sum of the numbers in the list - """ - # FIXME 7: find the sum of the numbers in the list and return it - ans = 0 - return ans - - -def answer(scores: List[int]) -> str: - """Find and return the answer as a string. - Args: - scores (List[int]): List of 5 contestants scores - Returns: - str: index of the max score + 1 and the max score as a string - """ - max_score = max(scores) - index = scores.index(max_score) - # FIXME 8: return the index+1 and the max number in the list as a string - - -if __name__ == "__main__": - main() diff --git a/labs/lists/pet/test_pet.py b/labs/lists/pet/test_pet.py deleted file mode 100644 index 347cba5..0000000 --- a/labs/lists/pet/test_pet.py +++ /dev/null @@ -1,38 +0,0 @@ -"""Moduel to test important function in pet.py. -""" - -import pet - - -def test_answer() -> None: - """Tests answer function.""" - ans = pet.answer([10, 20, 11, 15, 13]) - expected = "2 20" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -def test_answer2() -> None: - """Tests answer function.""" - ans = pet.answer([6, 10, 8, 4, 15]) - expected = "5 15" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - -# FIXME 1: add a test case function to test answer function -# FIXME 2: add a test case function to test answer function - - -def test_list_sum() -> None: - """Tests list_sum function.""" - ans = pet.list_sum([6, 7, 8, 10]) - expected = 31 - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -def test_list_sum2() -> None: - """Tests list_sum function.""" - ans = pet.list_sum([2, 3, 4, 5]) - expected = 14 - assert ans == expected, f"Expected: {expected}, but got: {ans}" - -# FIXME 3: add a test case function to test list_sum function -# FIXME 4: add a test case function to test list_sum function diff --git a/labs/loops/oddities/README.md b/labs/loops/oddities/README.md deleted file mode 100644 index e4e4de9..0000000 --- a/labs/loops/oddities/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# CS0 Lab - Loops and Unittesting - -Possible Points: 100 - -Write a Python program to solve the Kattis problem - Oddities [https://open.kattis.com/problems/oddities](https://open.kattis.com/problems/oddities). Read the problem statement carefully to design a correct solution using unittest. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create lab folder **oddities** inside your CS0Lab-... repository -3. Inside the lab folder, create two files. -4. Type the partial code stub provided and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -```note -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Run unit test using pytest and create screenshot when all the test cases pass. Install pytest if required. Pick one of the following ways to run pytest. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest . - $ python -m pytest . -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the solution script to Kattis. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -10. Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/loops/oddities/oddities.py b/labs/loops/oddities/oddities.py deleted file mode 100644 index b861aeb..0000000 --- a/labs/loops/oddities/oddities.py +++ /dev/null @@ -1,69 +0,0 @@ -""" -Loops and Unittest Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve - Oddities: https://open.kattis.com/problems/oddities - -Algorithm: - 1. Read N - 2. Repeat N times: - i. Read the input number - ii. Check if the number is odd or even - iii. Print the result as shown in the sample output -""" - - -def odd_even(number: int) -> str: - """Checks if the number is odd or even - - Args: - number (int): number to check odd or even - - Returns: - str: 'odd' if the number is odd, 'even' otherwise - """ - # FIXME 1: if the number divided by 2 has 0 remainder, return 'even' - # otherwise, return 'odd' - ans = "FIXME" - return ans - - -def main() -> None: - """Main function that solves the problem - """ - # step 1. read data - N = read_int_data() - # FIXME 2 - step 2. repeat the following N times - # FIXME 2.i - read the input number using read_int_data function - # FIXME 2.ii - call answer function passing the number as an argument - # FIXME 2.iii - print the answer as shown in the sample output - - -def read_int_data() -> int: - """Reads the data from std input and returns it - - Returns: - int: data read from std input as an int - """ - # FIXME 3: using input read and store the data into data variable - # FIXME 4: convert the data into an int and return it - - -def answer(num: int) -> str: - """Creates the final answer and returns it given the number - - Args: - num (int): number to check odd or even - - Returns: - bool : True if the number is even, False otherwise - """ - ans = odd_even(num) - return f'{num} is {ans}' - - -if __name__ == "__main__": - # FIXME 10: call correct entry function - pass diff --git a/labs/loops/oddities/test_oddities.py b/labs/loops/oddities/test_oddities.py deleted file mode 100644 index 0e1d87d..0000000 --- a/labs/loops/oddities/test_oddities.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Test cases for oddities.py""" -import oddities - - -def test_answer(): - """Test answer function.""" - ans = oddities.answer(10) - expected = "10 is even" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -def test_answer2(): - """Test answer function for negavitve odd number.""" - ans = oddities.answer(-199) - expected = "-199 is odd" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -# FIXME 6: add a new test case function to test your answer function - -# FIXME 7: add a new test case function to test your answer function - - -def test_odd_even(): - """Test odd_even function. - """ - ans = oddities.odd_even(10) - expected = "even" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -def test_odd_even2(): - """Test odd_even function for negavitve odd number - """ - ans = oddities.odd_even(-199) - expected = "odd" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -# FIXME 8: add a new test case function to test your answer function - -# FIXME 9: add a new test case function to test your answer function diff --git a/labs/math/addtwonumbers/README.md b/labs/math/addtwonumbers/README.md deleted file mode 100644 index 78fba2d..0000000 --- a/labs/math/addtwonumbers/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# CS0 Lab - Math - -Possible Points: 100 - -Write a Python program to solve the Kattis problem: addtwonumbers [https://open.kattis.com/problems/addtwonumbers](https://open.kattis.com/problems/addtwonumbers). Read the problem statement carefully to design a correct solution. - -### Lab Instructions - -1. Create your account at [https://open.kattis.com](https://open.kattis.com). Change your university affiliation to Colorado Mesa University if you want to see your rank. -2. Open your CS0Lab-... repo in VS Code -2. Create lab folder **math** inside your CS0Lab-... repository -3. Inside the lab folder, create a file: main.py -4. Type the partial code stub provided in main.py file and fix all fixmes. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -```txt -IMPORTANT: Never ask the user telling what to do for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -7. Upload only the .py file(s) to Kattis for testing. You can check your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -8. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -9. Update your README file (10 points) as shown here: https://github.com/rambasnet/csci000-astudent - -## Submission - -Add all the relevant source file(s) and documents, screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. -NOTE: Do not add and commit to this lab folder after the due date as it may be considered late submission! diff --git a/labs/math/addtwonumbers/main.py b/labs/math/addtwonumbers/main.py deleted file mode 100644 index d39c7ea..0000000 --- a/labs/math/addtwonumbers/main.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -Math and Variables Lab -By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve: Add Two Numbers - https://open.kattis.com/problems/addtwonumbers - -Algorithm steps: - 1. Read data as a line - 2. Split the line into two integers - 3. Add them up - 4. print the result -""" - -import sys - - -def main(): - """Main function that solves the problem - """ - - # FIXME1 - read input data into a variable #fixed# - line = input() - # split the data into two numbers - a, b = line.split() - # check to see if the data is split correctly - print(f'{a=}, {b=}', file=sys.stderr) - # FIXME 2: convert string a into integer - # FIXME 3: convert string b into integer - # FIXME 4: add two numbers and store the result into ans variable - # FIXME 5: print the answer as shown in the sample output - - -main() # call main function diff --git a/labs/oop/README.md b/labs/oop/README.md deleted file mode 100644 index 630a685..0000000 --- a/labs/oop/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# CS0 Lab - OOP and Unittesting - -Possible Points: 100 - -Write a Python program to solve the Kattis problem - Bijele - [https://open.kattis.com/problems/bijele](https://open.kattis.com/problems/bijele) . Read the problem statement carefully to design a correct solution using OOP and unittest. - -## Install Kattis-cli - -- if you've installed kattis-cli before, update it to the latest version - -```bash -$ pip install -U kattis-cli -$ python -m pip install -U kattis-cli -``` - -- if you've not installed kattis-cli before, install it - -```bash - $ pip install kattis-cli - $ python -m pip install kattis-cli -``` - -## Setup Kattis-cli - -- setup kattis-cli by providing logging in to Kattis using your Kattis username and password - -```bash -kattis setup -``` - -## Lab Instructions - -- Open your CS0Lab-... repo in VS Code -- Create lab folder **oop** inside your CS0Lab-... repository -- Inside the lab folder, download the problem metadata and sample files for the problem **bijele** using Kattis-clis - -```bash -kattis get bijele -``` - -- Inside **bijele** folder, type the partial code stub provided and fix all FIXMEs. (80 points) -- Follow best programming practices by using proper white spaces, comments, etc. -` -- Run unit test using pytest and create screenshot when all the test cases pass. Install pytest if required. Pick one of the following ways to run pytest. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest . - $ python -m pytest . -``` - - -- Test the whole program using Katts-cli. (10 points) - -```bash -$ cd bijele -$ kattis test -``` - -- Create the screenshot of the correct local test result. (10 points) -- Submit the solution to Kattis using Kattis-cli. (10 points) - -```bash -$ cd bijele -$ kattis submit -``` - -- Create screenshot of the kattis final Accepted verdict and save it to the lab folder. (10 points) - -- Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/oop/bijele/bijele.py b/labs/oop/bijele/bijele.py deleted file mode 100644 index 435b64f..0000000 --- a/labs/oop/bijele/bijele.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Date: FIXME - -Using OOP concept, solve: Bijele - https://open.kattis.com/problems/bijele - -Algorithm: - 1. Create chess.py module to define the the Chess class - 2. Define the __init__ method to initialize the Chess class - 3. Define the __str__ method to return the string representation of the Chess class - 4. Define the __sub__ method to return the difference between two Chess objects - 5. print the difference as shown in the sample output -""" - -from chess import Chess - - -def main() -> None: - # the actual chess pieces count - actual_chess = Chess(1, 1, 2, 2, 2, 8) - # FIXME - read the chess pieces count from the input - pieces = 0, 0, 0, 0, 0, 0 # FIXME - given_chess = Chess(*pieces) - # FIXME - create a Chess object using the input data - # FIXME - print the difference between the actual and input chess pieces count - ans = actual_chess - given_chess # creates a new Chess object - print(ans) - - -if __name__ == "__main__": - main() diff --git a/labs/oop/bijele/chess.py b/labs/oop/bijele/chess.py deleted file mode 100644 index 7ac1d65..0000000 --- a/labs/oop/bijele/chess.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Module to define the Chess class. -""" - - -class Chess: - def __init__(self, king=1, queen=1, rooks=2, bishops=2, knights=2, pawns=8): - self.king = king - self.queen = queen - # update the rest of the attributes using the arguments - self.rooks = 0 # FIXME - self.bishops = 0 # FIXME - self.knights = 0 # FIXME - self.pawns = 0 # FIXME - - def __str__(self): - return f'{self.king} {self.queen} {self.rooks} {self.bishops} {self.knights} {self.pawns}' - - def __sub__(self, other: 'Chess'): - k_diff = self.king - other.king - q_diff = self.queen - other.queen - r_diff = self.rooks - other.rooks - # FIXME - update the rest of the attributes' differences - b_diff = 0 # FIXME - kn_diff = 0 # FIXME - p_diff = 0 # FIXME - return Chess(k_diff, q_diff, r_diff, b_diff, kn_diff, p_diff) diff --git a/labs/oop/bijele/test_chess.py b/labs/oop/bijele/test_chess.py deleted file mode 100644 index ceb123d..0000000 --- a/labs/oop/bijele/test_chess.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -Module to test the Chess class. -""" - -from chess import Chess - - -def test__init__() -> None: - """Test the __init__ method""" - chess = Chess(1, 1, 2, 2, 2, 8) - assert chess.king == 1 - assert chess.queen == 1 - assert chess.rooks == 2 - assert chess.bishops == 2 - assert chess.knights == 2 - assert chess.pawns == 8 - -# add two test function to __init__ method to test the attributes are correctly initialized - - -def test__str__() -> None: - """Test the __str__ metho""" - chess = Chess() - assert str(chess) == '1 1 2 2 2 8' - - -# add two test function to __str__ method to test the string representation is correct - -def test__diff__(): - """Test the __sub__ method""" - chess1 = Chess(1, 1, 2, 2, 2, 8) - chess2 = Chess(0, 1, 1, 2, 1, 8) - chess3 = chess1 - chess2 - assert chess3.king == 1 - assert chess3.queen == 0 - assert chess3.rooks == 1 - assert chess3.bishops == 0 - assert chess3.knights == 1 - assert chess3.pawns == 0 - - -# add two test function to __sub__ method to test the difference is correct diff --git a/labs/stdio/ascii/README.md b/labs/stdio/ascii/README.md deleted file mode 100644 index 95b7923..0000000 --- a/labs/stdio/ascii/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# CS0 - Lab - Variables and Std IO - ASCII Art - -Possible points: 100 - -## Variables and Std IO Lab: ASCII Art - -Write a Python program that displays some ASCII arts on to the Console/Terminal or standard output using variables. - -### Lab Instructions - -1. Setup GitHub account if not done already; follow instructions in Lab 0 -2. Open your repo folder -3. Create a lab folder: ascii -4. In ascii folder, create a new file: main.py -7. Type the code stub in main.py file as a hint to complete the lab -8. Never copy-paste code; you’ll not learn anything by doing so! -9. Type each line of code and use incremental development techniques to learn what the given code does and what happens when you add each line(s) of new code to complete your lab. -6. Do git add, commit and push as often as possible after every significant improvement or after each fixme is fixed and tested so you are familiar with the git commands, and you have a working backup. -10. Add, and commit files to local git repo then push to remote. - * $ git add main.py - * $ git commit -m “create main.py file” - * $ git push -10. Fix all the FIXMEs and write #fixed# at the end of each FIXME that’s fixed except at the end of your name and date. -11. The completed lab should produce an output that looks like the following: -a. Note: replace the placeholder < > with actual value/data. - -``` - |\_/| ***************************** (\_/) - / @ @ \ * ASCII Lab * (='.'=) - ( > 0 < ) * * ( " )_( " ) - >>x<< * * - / O \ * CSCI 110 * - ***************************** -``` - -Note: The figure on the right (looks like a mouse) uses both single ( ' ) and double quotes ( " ) and you must find a way to print both single and double quotes as shown. - -12. Create a screenshot of the completed program with the final output displayed on the Terminal and save it to the current lab folder. (10 points) -13. When done, update your README file (10 points) as shown here: https://github.com/rambasnet/csci000-astudent -14. All FIXMEs are worth equal points unless stated otherwise. - -## Submission - -Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your remote GitHub. diff --git a/labs/stdio/ascii/main.py b/labs/stdio/ascii/main.py deleted file mode 100644 index 60e38a4..0000000 --- a/labs/stdio/ascii/main.py +++ /dev/null @@ -1,40 +0,0 @@ -""" - StdIO Lab - ASCII Art - using literals and variables - - Updated By: #FIXME1 - Date: ... #FIXME2 - - This program produces an ASCII art on the console. - - Algorithm steps: - 1. Use variables to store data/values - 2. Write a series of print statements to print the data/values to the console -""" - -print("Welcome to ASCII Art Program...\n") - -# FIXME3: prompt user to enter their name and store the value into name variable using input function -# FIXME4: greet the name using the variable as the following output -# must output: Nice meeting you, ! - -# prompt user to enter the semester and store the value into semester variable using input function -semester: str = input("What semester is this [Fall/Spring]? ") -print("This is " + semester + " semester.\n") - -# FIXME5: prompt user to enter the year and store the value into year variable using input function -# FIXME6: print the year using the variable as the following output -# must output: This is year. - -print("Hope you like my ASCII art...\n\n") - -line1: str = " |\\_/| ********************** (\\_/)\n" -print(line1) - -# FIXME7: use variable to print the second line of the graphic -# FIXME8: print the third line of the graphics -# FIXME9: use variable to print the fourth line -# FIXME10: use variable to print the fifth line -# Note: You can add more lines or print more ASCII arts of your choice if you'd like... - -print("\nGood bye... \n") diff --git a/labs/strings/simonsays/README.md b/labs/strings/simonsays/README.md deleted file mode 100644 index 942acdb..0000000 --- a/labs/strings/simonsays/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# CS0 Lab - Strings - -Possible Points: 100 - -Write a Python program to solve the Kattis problem - Simon Says [https://open.kattis.com/problems/simonsays](https://open.kattis.com/problems/simonsays). Read the problem statement carefully to design a correct solution using unittest. - -## Lab Instructions - -1. Open your CS0Lab-... repo in VS Code -2. Create a lab folder **strings** inside your CS0Lab-... repository -3. Inside the lab folder, create two files: simonsays.py and test_simonsays.py -4. Type the partial code stub provided in the lab folder and fix all FIXMEs. (80 points) -5. Follow best programming practices by using proper white spaces, comments, etc. - -```note -IMPORTANT: Never ask the user telling what data to enter for Kattis problems. Kattis knows what to enter. -Directly read the input. Print only the answer as displayed in the sample output. -Print as asked: nothing less; nothing more! -Kattis is a computer program that provides specific input and expects exact output – to a space to give the correct verdict. -``` - -6. Run pytest on test module. Install pytest if required. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest . - $ python -m pytest . -``` - -7. Test the whole program manually. While testing, provide input using the same format as described in the Input section and shown in input samples. -8. Upload only the solution scripts to Kattis for testing. You can test your solution as many times as you wish. Kattis uses its own hidden test cases to test your program against. However, your goal is to get the accepted verdict in the first try. -9. Create screenshots showing your local testing and the kattis final Accept verdict and save them to the lab folder. (10 points) -10. Update your README file as shown here: https://github.com/rambasnet/csci000-astudent (10 points) - -## Submission - -Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m “Final Submission” -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com. diff --git a/labs/strings/simonsays/simonsays.py b/labs/strings/simonsays/simonsays.py deleted file mode 100644 index 4a7e4a2..0000000 --- a/labs/strings/simonsays/simonsays.py +++ /dev/null @@ -1,62 +0,0 @@ -""" -Strings and Unittest Lab -Updated By: FIXME -CSCI 110 Lab -Date: FIXME - -Read and solve - Simon Says: https://open.kattis.com/problems/simonsays - -Algorithm: - 1. Read N - 2. Repeat N times: - 1. Read the input string - 2. Check if the string begins with 'Simon says' - 3. If it does, print the rest of the string after 'Simon says', otherwise ignore the string -""" - -from typing import Union - - -def main(): - """Main function that solves the problem. - """ - # step 1. read data - N = int(input()) - # FIXME 1 - Repeat steps 2-4 N times - # FIXME 2 - read the input string - # FIXME 3 - call answer function passing the string as an argument - # FIXME 4 - print the answer if it returns one, otherwise ignore it - - -def valid_command(command: str) -> bool: - """Checks if the string starts with 'Simon says'. - - Args: - command (str): string to check. - - Returns: - bool: True if the string starts with 'Simon says', False otherwise. - """ - # FIXME 5: if the command begins with 'Simon says', return True - # otherwise, return False - ans = "FIXME" - return ans - - -def answer(command: str) -> Union[str, None]: - """Returns answer given the command or None if the command is not valid. - - Args: - command (str): string to check - - Returns: - str|None: rest of the string after 'Simon says' if the command is valid, None otherwise - """ - valid = valid_command(command) - # FIXME 6: if valid is True, return the rest of the string after 'Simon says', None otherwise - return None - - -if __name__ == "__main__": - # call the main function if the script is run from the command line - main() diff --git a/labs/strings/simonsays/test_simonsays.py b/labs/strings/simonsays/test_simonsays.py deleted file mode 100644 index 3acf915..0000000 --- a/labs/strings/simonsays/test_simonsays.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Test cases for simonsays.py -""" - -import simonsays - - -def test_valid_command(): - """Test valid_command function. - """ - ans = simonsays.valid_command("Simon says do this") - expected = True - assert ans == expected, f"Expected: {expected}, but got: {ans}" - - -def test_valid_command2(): - """Test valid_command function.""" - ans = simonsays.valid_command("do this") - expected = False - assert ans == expected, f"Expected: {expected}, but got: {ans}" - -# FIXME 7: add a new test case function to test valid_command function - -# FIXME 8: add a new test case function to test valid_command function - - -def test_answer(): - """Test answer function. - """ - ans = simonsays.answer("Simon says do this") - expected = " do this" - assert ans == expected, f"Expected: {expected}, but got: {ans}" - -# FIXME 9: add a new test case function to test answer function - -# FIXME 10: add a new test case function to test answer function diff --git a/labs/unittest/README.md b/labs/unittest/README.md deleted file mode 100644 index 81c2b8c..0000000 --- a/labs/unittest/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# CS0 Lab - OOP and Unittesting with Unittest Library - -Possible Points: 100 - -Write a Python program to solve the Kattis problem - Bijele - [https://open.kattis.com/problems/bijele](https://open.kattis.com/problems/bijele) . Read the problem statement carefully to design a correct solution using OOP and unittest. - -## Install and Use Kattis-cli - -- if you've installed kattis-cli before, update it to the latest version - -```bash -$ pip install -U kattis-cli -$ python -m pip install -U kattis-cli -``` - -- if you've not installed kattis-cli before, install it - -```bash - $ pip install kattis-cli - $ python -m pip install kattis-cli -``` - -## Setup Kattis-cli - -- setup kattis-cli by providing logging in to Kattis using your Kattis username and password - -```bash -kattis setup -``` - -## Lab Instructions - -- Open your CS0Lab-... repo in VS Code -- Create lab folder **unittest** inside your CS0Lab-... repository -- Inside the lab folder, download the problem metadata and sample files for the problem **bijele** using Kattis-clis -- Use previous lab **OOP and Unittesting** to complete this lab -- Must Use **unittest** library to write unit tests for the class methods -- Write at least two test methods for each class method you're testing - -```bash -kattis get bijele -``` - -- Inside **bijele** folder, type the partial code stub provided and fix all FIXMEs. (80 points) -- Follow best programming practices by using proper white spaces, comments, etc. -` -- Run unit test using pytest and create screenshot when all the test cases pass. Install pytest if required. Pick one of the following ways to run pytest. - -```bash - $ pytest --version - $ pip install -U pytest - $ pytest . - $ python -m pytest . -``` - - -- Test the whole program using Katts-cli. (10 points) - -```bash -$ cd bijele -$ kattis test -``` - -- Create the screenshot of the correct local test result. (10 points) -- Submit the solution to Kattis using Kattis-cli. (10 points) - -```bash -$ cd bijele -$ kattis submit -``` - -- Create screenshot of the kattis final Accepted verdict and save it to the lab folder. (10 points) - -- Update your README file (10 points) as shown here: [https://github.com/rambasnet/csci000-astudent](https://github.com/rambasnet/csci000-astudent) - -## Submission - -- Make sure to format the code using pep8 or black before submission. -- Add all the relevant source file(s), documents, and screenshots into the correct lab folder and do a final add, commit, and push before the due date. - -```bash -$ git pull -$ git status -$ git add … - add each file in the red that is part of this lab -$ git status -$ git commit -m "Final Submission" -$ git push -$ git status -``` - -- Check and make sure the files are actually pushed to your GitHub repo on github.com.