-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgramming_Assignment_23.py
More file actions
63 lines (46 loc) · 1.33 KB
/
Programming_Assignment_23.py
File metadata and controls
63 lines (46 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
1. **Is Symmetrical:**
```python
def is_symmetrical(num):
# Convert the number to a string
num_str = str(num)
# Check if the string is the same as its reverse
return num_str == num_str[::-1]
```
2. **Multiply Numbers:**
```python
def multiply_nums(num_str):
# Split the string by ", " to get a list of numbers
num_list = [int(num) for num in num_str.split(", ")]
# Multiply the numbers in the list
product = 1
for num in num_list:
product *= num
return product
```
3. **Square Digits:**
```python
def square_digits(num):
# Convert the number to a string
num_str = str(num)
# Square each digit and concatenate the results
squared_digits = "".join(str(int(digit)**2) for digit in num_str)
# Convert the result back to an integer
return int(squared_digits)
```
4. **Setify:**
```python
def setify(lst):
# Convert the list to a set to remove duplicates
return list(set(lst))
```
5. **Mean:**
```python
def mean(num):
# Convert the number to a string
num_str = str(num)
# Sum the digits and count the number of digits
digit_sum = sum(int(digit) for digit in num_str)
num_digits = len(num_str)
# Calculate the mean
return digit_sum // num_digits
```