George is getting tired of the decimal number system. He intends to switch and use the…
- User
George is getting tired of the decimal number system. He intends to switch and use the septenary (base 7) number system for his future needs. Write a program to help George start his transformation into the septenary number system by taking in a list of decimal numbers and print out the corresponding septenary number. Input A list of numbers in decimal format ending with -1.
Output A list of numbers in septenary.
Example Input: 1 2 88 42 99 -1
Output: 1 2 154 60 201
Assistant
pythondef decimal_to_septenary(n): if n == 0: return '0' digits = [] while n > 0: digits.append(str(n % 7)) n = n // 7 return ''.join(reversed(digits)) nums = input().split() decimal_numbers = list(map(int, nums[:-1])) septenary_numbers = [decimal_to_septenary(num) for num in decimal_numbers] print(' '.join(septenary_numbers))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.