Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I added two functions to cs50 python module. #188

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OmarSSpy
Copy link

@OmarSSpy OmarSSpy commented Feb 12, 2025

New functions for cs50

Based on my experience with python during cs50x week 6, I didnt understand much of how .csv files worked and how to read them but eventually I did understand how to read those files. So with these functions I think we can make learning easier in cs50x to less comfortable audiences.

Syntax

The first function reads a .csv file and handles some errors. The other function implements binary search, where you pass an array and the target you are looking for, this function returns the index of the target in the given array if successful.

read_csv function

y = read_csv(file:str)

binary_search function

x = binary_search(array, target)

###write_csv function

Writes a list of lists to a .csv file,

file : str

    The name (or path) of the CSV file to write to.

data : list
A list of lists, where each inner list represents a row in the CSV file.

data = [["Name", "Age"], ["Alice", 25], ["Bob", 30]]
write_csv("people.csv", data)

This function returns True if successfull or False if an error occurred.

I believe this changes will make easier lo learn python during the cs50x course,

Thank you.

…ds a csv file and handles some errors. The other function implements binary search, where you pass an array and the target you are looking for.
Copy link
Author

@OmarSSpy OmarSSpy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created two more functions for the user to use. One reads a csv and returns the values read. The other function implements binary search as a function that returns the index of the target in the list given

@OmarSSpy
Copy link
Author

@rongxin-liu
Can you review my pull request please or tell anyone else to check it

@rongxin-liu rongxin-liu requested a review from dmalan February 12, 2025 22:21
@OmarSSpy
Copy link
Author

OmarSSpy commented Feb 12, 2025

Thanks rongxin-liu for asking professor malan :)

By the way @dmalan , if you need me to change anything feel free to tell me and I just wanted to say you are an incredible teacher. I love how you teach computer science because I am currently taking CS50x and its AWESOME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant