Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

first and last digit codechef solution

t=int(input())
for i in range(t):
    x=str(input())
    a=int(x[0])
    b=int(x[-1])
    c=a+b
    print(c)
Comment

First and Last Digit codechef solution in c++

#include<iostream>
using namespace std;
// Get first number
int first_number(int n)
{
	while (n > 9)
	{
		n /= 10;
	}
	return n;
}
// Get last number
int last_number(int n)
{
	return n %= 10;
}
int main()
{
	int t, n, sum;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n;
		sum = 0;
		sum = first_number(n) + last_number(n);
		cout << sum << "
";
	}
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Python :: split datetime to date and time pandas 
Python :: how to add window background in pyqt5 
Python :: binary to decimal conversion python 
Python :: pygame size of image 
Python :: change default port django 
Python :: for one line python 
Python :: how to use h5 file in python 
Python :: menubar pyqt 
Python :: convert list to numpy array 
Python :: start python virtual 
Python :: how to read multiple csv file from different directory in python 
Python :: fork function in python 
Python :: how to convert boolean type list to integer 
Python :: takes 1 positional argument but 2 were given python 
Python :: button in python 
Python :: give a function a name python 
Python :: get required packages from python project 
Python :: create virtual environments python 
Python :: how to redirect to previous page in django 
Python :: python substring 
Python :: python how to delete a directory with files in it 
Python :: [0] * 10 python 
Python :: suppress python 
Python :: access django server from another machine 
Python :: python super 
Python :: python iterate files 
Python :: python tkinter get image size 
Python :: how to use fastapi ApiClient with pytest 
Python :: np.zeros 
Python :: python initialize dict with empty list values 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =