<!-- Day page sponsor slot: empty, so nothing is shown. When sold, add the line below
     right under this comment. Logo 120x40 px (send 240x80), text up to 60 characters:
     <p align="right"><sub>Sponsored</sub><br><a href="URL?ref=github-day-09"><img src="../assets/sponsors/NAME.png" height="40" align="middle" alt="NAME"></a>&nbsp; <a href="URL?ref=github-day-09">One-line message →</a></p> -->

<!-- day-nav:top -->
<p align="center"><a href="Day%208.md">← Day 8</a> &nbsp;·&nbsp; <a href="../README.md#days">All 24 days</a> &nbsp;·&nbsp; <a href="Day_10.md">Day 10 →</a></p>
<!-- /day-nav:top -->

# Question 26

### **Question:**

> **_Define a function which can compute the sum of two numbers._**

---

### Hints:

> **_Define a function with two numbers as arguments. You can compute the sum in the function and return the value._**

---

<details markdown="1">
<summary><b>💡 Show solutions</b> (try it yourself first!)</summary>

**Main author's Solution: Python 2**

```python
def SumFunction(number1, number2):
	return number1 + number2

print SumFunction(1,2)
```

---

**My Solution: Python 3**

```python
sum = lambda n1,n2 : n1 + n2      # here lambda is use to define little function as sum
print(sum(1,2))
```


</details>

---

# Question 27

### **Question:**

> **_Define a function that can convert a integer into a string and print it in console._**

---

### Hints:

> **_Use str() to convert a number to string._**

---

<details markdown="1">
<summary><b>💡 Show solutions</b> (try it yourself first!)</summary>

**Main author's Solution: Python 2**

```python
def printValue(n):
	print str(n)

printValue(3)
```

---

**My Solution: Python 3**

```python
conv = lambda x : str(x)
n = conv(10)
print(n)
print(type(n))            # checks the type of the variable
```


**Solution by VK**
```python
def ConvertStrToInt (data):
    if type(data) == int:
        return str(data)
    else:
        return f'Expected int, received {type(data)}'
x = 10
print(type(ConvertStrToInt(x)))
print(ConvertStrToInt(x))
```


</details>

---

# Question 28

### **Question:**

> **_Define a function that can receive two integer numbers in string form and compute their sum and then print it in console._**

---

### Hints:

> **_Use int() to convert a string to integer._**

---

<details markdown="1">
<summary><b>💡 Show solutions</b> (try it yourself first!)</summary>

**Main author's Solution: Python 2**

```python
def printValue(s1,s2):
	print int(s1) + int(s2)
printValue("3","4") #7
```

---

**My Solution: Python 3**

```python
sum = lambda s1,s2 : int(s1) + int(s2)
print(sum("10","45"))      # 55
```
**Solution by VK: Python 3**

```python
def ConvertStrAndSum():
    counter = 0
    while counter == 0:
        try:
            value = input('Enter 2 value to sum it\n').split()
            x, y = value
            try:
                x, y = int(x), int(y)
                counter += 1
                return x + y
            except ValueError as err:
                print(err)
        except ValueError or UnboundLocalError as err:
            print(err)

print(ConvertStrAndSum())
```



</details>

---

# Question 29

### **Question:**

> **_Define a function that can accept two strings as input and concatenate them and then print it in console._**

---

### Hints:

> **_Use + sign to concatenate the strings._**

---

<details markdown="1">
<summary><b>💡 Show solutions</b> (try it yourself first!)</summary>

**Main author's Solution: Python 2**

```python
def printValue(s1,s2):
	print s1 + s2

printValue("3","4") #34
```

---

**My Solution: Python 3**

```python
sum = lambda s1,s2 : s1 + s2
print(sum("10","45"))        # 1045
```

**Solution from VK**

```python
def concatenate_str(*args):
    result_str = ''
    for n in args:
        result_str += n
    return print(result_str)
concatenate_str('05', '12', '2', '0', '2', '2')
```


</details>

---

# Question 30

### **Question:**

> **_Define a function that can accept two strings as input and print the string with maximum length in console. If two strings have the same length, then the function should print all strings line by line._**

---

### Hints:

> **_Use len() function to get the length of a string._**

---

<details markdown="1">
<summary><b>💡 Show solutions</b> (try it yourself first!)</summary>

**Main author's Solution: Python 2**

```python
def printValue(s1,s2):
	len1 = len(s1)
	len2 = len(s2)
	if len1 > len2:
		print s1
	elif len2 > len1:
		print s2
	else:
		print s1
		print s2

printValue("one","three")

```

---

**My Solution: Python 3**

```python
def printVal(s1,s2):
    len1 = len(s1)
    len2 = len(s2)
    if len1 > len2:
        print(s1)
    elif len1 < len2:
        print(s2)
    else:
        print(s1)
        print(s2)

s1,s2=input().split()
printVal(s1,s2)
```

---

```python
'''Solution by: yuan1z'''
func = lambda a,b: print(max((a,b),key=len)) if len(a)!=len(b) else print(a+'\n'+b)
```

---
---

```python
'''Solution by: VK'''
def str_len():
    x = []
    new_li = []
    while True:
        y = input('Enter text\n')
        if not y:
            break
        x.append(y)
    man_len = max(x, key=len)
    for i in x:
        if len(man_len) == len(i):
            new_li.append(i)
    print('\n'.join(new_li))
str_len()
```

---

'''python
'''Solution by: chinmaybhole'''
a,b = input().split(',')
max_len = lambda a,b: a+b if len(a)==len(b) else a if len(a)> len(b) else b
print(max_len(a,b))
'''


</details>

---

<!-- day-nav:bottom -->
<p align="center">
<sub><b>UP NEXT</b></sub><br>
<a href="Day_10.md"><img src="../assets/days/day-10.svg" width="240" alt="Day 10, questions 31 to 37: Dicts &amp; lists in functions"></a><br>
<a href="Day%208.md">← Day 8</a> &nbsp;·&nbsp; <a href="../README.md#days">All 24 days</a>
</p>
<!-- /day-nav:bottom -->

[**_Discussion_**](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3)
