mirror of
https://github.com/friuns2/BlackFriday-GPTs-Prompts.git
synced 2026-05-01 22:43:53 +07:00
2024 chatgpt update
This commit is contained in:
+42
-2
@@ -1,5 +1,5 @@
|
||||
|
||||
[](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22zBRTXPXdh-lYCKPoA9_hk%22%2C%22flow%22%3Atrue%7D%7D)
|
||||
|
||||
# FasilG | [Start Chat](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22zBRTXPXdh-lYCKPoA9_hk%22%2C%22flow%22%3Atrue%7D%7D)
|
||||
This prompt is good.
|
||||
|
||||
@@ -10,6 +10,47 @@ Given a list of integers, write a function in Python that returns the sum of all
|
||||
numbers in the list.
|
||||
```
|
||||
|
||||
## Welcome Message
|
||||
Sure! Here's a Python function that takes a list of integers as input and returns the sum of all even numbers in the list:
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
def sum_of_even_numbers(numbers):
|
||||
|
||||
even_sum = 0
|
||||
|
||||
for num in numbers:
|
||||
|
||||
if num % 2 == 0: # check if number is even
|
||||
|
||||
even_sum += num # add even number to sum
|
||||
|
||||
return even_sum
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
You can use this function by calling it and passing a list of integers as an argument:
|
||||
|
||||
|
||||
|
||||
```python
|
||||
|
||||
numbers = [1, 2, 3, 4, 5, 6]
|
||||
|
||||
result = sum_of_even_numbers(numbers)
|
||||
|
||||
print(result) # Output: 12
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
In this example, the list `[1, 2, 3, 4, 5, 6]` contains the even numbers 2, 4, and 6. The function `sum_of_even_numbers()` calculates the sum of these even numbers, which is 12.
|
||||
|
||||
## Conversation
|
||||
|
||||
**ASSISTANT**: Sure! Here's a Python function that takes a list of integers as input and returns the sum of all even numbers in the list:
|
||||
@@ -52,4 +93,3 @@ print(result) # Output: 12
|
||||
|
||||
In this example, the list `[1, 2, 3, 4, 5, 6]` contains the even numbers 2, 4, and 6. The function `sum_of_even_numbers()` calculates the sum of these even numbers, which is 12.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user