Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Mayan numerals # The Mayan civilisation used base 20 numeral system. The numerals were # made of three symbols: a shell shell which represented 0, a dot which # represented 1 and a bar which represented five. We will use the following # characters: 'O' (for zero), '.' (for one), ':' (for two) and 'T' (for five). # # The number 0 is therefore represented by 'o', the number 1 with '.', # while the number 2 has two possible representations: '..' and ':'. # The number 3 can be represented by three different strings: ' # and '.:'. The number 4 can be represented in several different ways: '::', etc. The number 7 has even more possible # representations: '..', ':l', '::... ..::.', '::.:', etc. # # To write any number in Mayan we have to first express it in base 20, # for example # # 967 = 7 * 20**0 + 8 * 20**1 + 2 * 20**2 = 7 + 8 * 20 + 2 * 400. + # We express each digit as described above and seperate then by spaces. # The number 967 becomes '|..:.::. ..' or ':.:.:'. Those are just # two possibilities. ########### #################### ##### ## # # # Write a function get_value (mayan) that gets a single argument: a # string mayan with the Mayan representation of the number. The function # should return an integer, i.e. the value of that number. # Examples: # # # # >>> get_value(':|.|.') 14 >>> get_value('|.:. .:.') 194 >>> get_value('..:.::...') 967 >>> get_value('0:.:.') 120 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Mayan numerals # The Mayan civilisation used base 20 numeral system. The numerals were # made of three symbols: a shell shell which represented 0, a dot which # represented 1 and a bar which represented five. We will use the following # characters: 'O' (for zero), '.' (for one), ':' (for two) and 'T' (for five). # # The number 0 is therefore represented by 'o', the number 1 with '.', # while the number 2 has two possible representations: '..' and ':'. # The number 3 can be represented by three different strings: ' # and '.:'. The number 4 can be represented in several different ways: '::', etc. The number 7 has even more possible # representations: '..', ':l', '::... ..::.', '::.:', etc. # # To write any number in Mayan we have to first express it in base 20, # for example # # 967 = 7 * 20**0 + 8 * 20**1 + 2 * 20**2 = 7 + 8 * 20 + 2 * 400. + # We express each digit as described above and seperate then by spaces. # The number 967 becomes '|..:.::. ..' or ':.:.:'. Those are just # two possibilities. ########### #################### ##### ## # # # Write a function get_value (mayan) that gets a single argument: a # string mayan with the Mayan representation of the number. The function # should return an integer, i.e. the value of that number. # Examples: # # # # >>> get_value(':|.|.') 14 >>> get_value('|.:. .:.') 194 >>> get_value('..:.::...') 967 >>> get_value('0:.:.') 120 #
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started