Assignment
University
University of ReginaCourse
Computer Science (UR)Pages
1
Academic year
2023
Avaiya Priyank
Views
0
p {margin: 0; padding: 0;} .ft00{font-size:23px;font-family:Calibri-Light;color:#000000;} .ft01{font-size:16px;font-family:Calibri;color:#000000;} .ft02{font-size:23px;line-height:31px;font-family:Calibri-Light;color:#000000;} 10. (a) One way to find out the last digit of a number is to mod the number by 10. Write a program that asks the user to enter a power. Then find the last digit of 2 raised to that power. (b) One way to find out the last two digits of a number is to mod the number by 100. Write a program that asks the user to enter a power. Then find the last two digits of 2 raised to that power. #last digit of 2 raise to power n=int(input("Enter the power: ")) a=2**n print("Last digit is : ", a%10) #last two digit of 2 raise to power print("Last two digit is : ", a%100)
Calculating the Last Two Digits of 2 Raised to a Power in Python
Please or to post comments