First digit of number in python

Description

Python program to get input num and display the first digit of number num
Input:
675
Output:
6

Solution

n=int(input("Enter n value:"))
while(n>10):
    n=n//10
print(n)
    

Explanation

Given number is continously divided by 10, till it becomes lesser than 10 and greater than 0. and the final answer is first digit of given number.



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution