Python
Instructions:
- Complete each of the following questions by writing a Python function.
- Test your functions with various inputs to ensure they work correctly.
- Submit your code along with comments explaining your approach and any assumptions made.
Question 1: List Operations
*Function: `list_summary(numbers)`
Description: Write a function `list_summary(numbers)` that takes a list of integers and returns a tuple containing:
1. The sum of the integers in the list.
2. The average of the integers in the list (rounded to 2 decimal places).
3. The maximum value in the list.
4. The minimum value in the list.
Example:
```python
list_summary([10, 20, 30, 40, 50])
```
Output:
```python
(150, 30.0, 50, 10)
```
Question 2: Filtering Lists
Function: `filter_even_numbers(numbers)`
Description: Write a function `filter_even_numbers(numbers)` that takes a list of integers and returns a new list containing only the even numbers from the original list.
Example:
```python
filter_even_numbers([1, 2, 3, 4, 5, 6])
```
Output:
```python
[2, 4, 6]
```
### Question 3: List Transformation
Function: `transform_list(numbers)`
Description: Write a function `transform_list(numbers)` that takes a list of integers and returns a new list where each element is the square of the original element plus 5.
Example:
```python
transform_list([1, 2, 3, 4])
```
Output:
```python
[6, 9, 14, 21]
```
=
Question 4: Append and Remove Operations
Function: `append_and_remove(numbers, to_append, to_remove)`
Description: Write a function `append_and_remove(numbers, to_append, to_remove)` that performs the following operations on a list of integers:
1. Append: Append the integer `to_append` to the end of the list.
2. Remove: Remove all occurrences of the integer `to_remove` from the list.
3. Return the modified list.
Example:
append_and_remove([1, 2, 3, 4], 5, 2)
```
Output*:
[1, 3, 4, 5]
Views: 11
Comments:
- nick: a (2024-09-02 21:10:13)
- : te (2024-09-01 15:52:20)
- CBAT: CBAT (2024-08-24 19:34:38)
- deven32@tf-info.com: (2024-08-24 03:59:32)
- antonette24@tf-info.com: (2024-08-24 03:47:39)
- joanna.miller@tf-info.com: (2024-08-24 03:45:01)
- bitch: fuck you for infecting my vm (2024-08-24 03:26:31)
- darkflux: and the comments are AAAAAAAAAALLLLL linked, lol (2024-08-01 00:19:51)
- darkflux: looks like there's nothing but scammers on this website... (2024-08-01 00:19:04)
- belle delphine: https://lootdest.org/s?630da0ff (2024-07-26 17:53:24)
- <>: <>zzz (2024-07-11 21:44:17)
- : zzz (2024-07-11 21:44:17)
- teen nudes: https://nempth.in/invite/89MXX3 (2024-07-08 01:58:20)
- sadasd: sdasd (2024-06-28 16:40:00)
- s: lol (2024-05-18 17:55:53)
- Mod: Use this method on Bitrefiller.com instead. Works faster and faster refund: https://mega.nz/file/tZRTWSLZ#MXHJ_YB05RaAWNQ7YzH-4WeqN5IHBtdeMjRHlRSPF7o (2024-05-12 03:04:06)
- shit nygga: shit nygga (2024-04-07 22:31:50)
- shit nygga: shit nygga (2024-04-07 22:31:48)
- shit nygga: shit nygga (2024-04-07 22:31:46)
- bruh: shitty ass website (2024-04-03 07:18:31)
- '": '" (2024-03-26 04:16:57)
- ...?: Why are all the pastes comments the same? (2024-03-13 06:23:52)
- marcus: holy shit it works (2024-03-12 01:56:23)
- test: test comment (2024-03-05 11:39:19)
- eh: i think badcord is glitching out (2024-03-03 19:41:06)
- : (2024-03-03 19:40:13)
- k: k (2024-02-17 14:14:51)
- k: k (2024-02-17 14:14:41)
- e_g.: hi this script has been patched by my filter (2024-02-08 15:58:08)
- KKosty4ka: are you actually fucking retarded or something? (2024-02-08 15:51:36)
- brickg: orks! (2024-01-30 18:58:21)
- lgf: WORKS! (2024-01-30 18:58:01)
- aee: works! (2024-01-30 18:53:33)
- aee: works! (2024-01-30 18:53:24)
- oyasumi8: there is my gmail but i dont think that is my username
+ the ip is from the hotel where i was, not mine (2023-10-13 15:05:19)
- .: . (2023-10-07 18:38:44)
- nick360: verified 検 (2023-10-01 06:38:28)
Add a Comment: