178k views
3 votes
Hey, can somebody convert this Pseudocode into a Python Program, I've been struggling to do so for a while.

Hey, can somebody convert this Pseudocode into a Python Program, I've been struggling-example-1

1 Answer

0 votes

Answer:

print("Enter a positive whole number: ")

NumberIn = int(input())

NumberOut = 0

Count = 0

while NumberIn > 0:

Count = Count + 1

PartValue = NumberIn % 2

NumberIn = NumberIn // 2

for i in range(1, Count - 1):

PartValue = PartValue * 10

NumberOut = NumberOut + PartValue

print("The result is: " + str(NumberOut))

Outputs:

Enter a positive whole number:

22

The result is: 1011

Enter a positive whole number:

29

The result is: 1111

Enter a positive whole number:

-1

The result is: 0

User Lei
by
3.8k points