- Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathq17.py
40 lines (30 loc) · 713 Bytes
/
q17.py
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
# If Give an integer N . Write a program to obtain the sum of the first and last digit of this number.
# Input
# The first line contains an integer T, total number of test cases. Then follow T lines, each line contains an integer N.
# Output
# Display the sum of first and last digit of N.
# Constraints
# 1 ≤ T ≤ 1000
# 1 ≤ N ≤ 1000000
# Example
# Input
# 3
# 1234
# 124894
# 242323
# Output
# 5
# 5
# 5
defLastDigit(a):
returna%10
defFirstDigit(a):
# Remove last digit from number
# till only one digit is left
while(a>=10):
a/=10
returnint(a)
t=int(input())
foriinrange(t):
number=int(input())
print(LastDigit(number)+FirstDigit(number))