Python program to print sum of first and last digit of a number.
Algorithm:::
Flowchart:::
Program code:::
num=int(input('Enter a number '))
num1=num%10;
num2=num
while num2>=10:
num2=num2/10;
print num1+num2
Step 1: Read a number, num
Step 2: Compute num1=num%10
Step 3: Assign num2=num
Step 4: Repeat step 5 while num2=>10
Step 5: Compute num2=num2/10
Step 6: print num1+num2
Step 7: Stop
Flowchart:::
Program code:::
num=int(input('Enter a number '))
num1=num%10;
num2=num
while num2>=10:
num2=num2/10;
print num1+num2
Glad you used a semicolon in a python program
ReplyDeleteRead any 3 digit number from user and display sum of first and last digit of the same
ReplyDelete