-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Trying something random #4790
base: master
Are you sure you want to change the base?
Trying something random #4790
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @Chandika-04, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces a simple Python script named random.py
that suggests a random selection of fast food restaurants based on user input. The script defines a function chooseFastFood
that takes the number of desired options as input and returns a list of randomly chosen restaurants from a predefined list. It also includes a main
function to prompt the user for the number of options and print the result.
Highlights
- New Script: A new Python script
random.py
is added to provide a fast food recommendation service. - Random Choice Function: The
chooseFastFood
function randomly selects fast food restaurants from a list based on user input. - User Input: The script takes user input to determine the number of fast food options to suggest.
Changelog
- random.py
- Created a new file
random.py
. - Implemented the
chooseFastFood
function to select random fast food options. - Added a
main
function to handle user input and output the results. - Included a check to ensure the number of requested options does not exceed the number of available fast food places.
- Created a new file
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Trivia time!
What is the origin of the name 'Python' for the programming language?
Click here for the answer
The name 'Python' comes from the British comedy group Monty Python, as Guido van Rossum, the creator of Python, was a big fan of their work.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The code introduces a function to randomly choose fast food options from a list. It's a fun little script! Here are a few suggestions to improve the code's readability and robustness.
Summary of Findings
- Input Validation: The code should validate the user input to ensure it's a positive integer. This prevents potential errors and improves the user experience.
- Error Handling: The code could provide more informative feedback when the user requests too many options. Instead of a simple string, consider raising an exception or returning a more structured error message.
- Code Clarity: Consider using a constant for the list of fast food restaurants to improve readability and maintainability.
Assessment
The code is a good starting point, but it could benefit from some improvements in input validation, error handling, and code clarity. I recommend addressing the comments before merging. Feel free to request another review from Gemini via /gemini review
when you have addressed these comments and I'll take another look!
if numOptions < len(listOfFastFood): | ||
for i in range(numOptions): | ||
chosen.append(random.choice(listOfFastFood)) | ||
return chosen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chosen.append(random.choice(listOfFastFood)) | ||
return chosen | ||
else: | ||
return "You requested too many options." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num_str = input("How many options of fast food places would you like? ") | ||
print(chooseFastFood(int(num_str))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good practice to validate user input to ensure it's a valid integer and within a reasonable range. Add a try-except block to handle potential ValueError
if the user enters non-numeric input. Also, handle the ValueError
that might be raised by chooseFastFood
.
try:
num_str = input("How many options of fast food places would you like? ")
num = int(num_str)
print(chooseFastFood(num))
except ValueError as e:
print(e)
No description provided.