Home / Expert Answers / Computer Science / python-nbsp-write-a-python-program-in-a-file-called-odd-even-jupiter-py-to-solve-the-following-pr-pa900

(Solved): python  Write a Python program, in a file called odd_even_jupiter.py, to solve the following pr ...



python 

Write a Python program, in a file called odd_even_jupiter.py, to solve the following problem:
Juplans from Juplter are obsess
Write a Python program, in a file called odd_even_jupiter.py, to solve the following problem: Juplans from Juplter are obsessed about dividing everything on their planet into two groups; odd and even. The great Jupian, has asked you to divide the population of Jupiter into odd and even groups by looking at each Jupian's name and computing the sum of the ASCII decimal values of each character in the name and storing the name back into the list in the same position but with a " 1 " appended to it if the sum is odd or a " 0 " appended to it if the sum is even. At the end print the number of Jupians that fall in the odd group and the number that fall into the even group. Your program should include the following functions to generate the output: - function getsum which, given a name, obtains the sum of the ASCll decimal values for each character in the name. - function updatelist which, given a list of names, uses a loop and calls the getsum function to find the ASCil decimal sum of the characters in each name, decides and changes each name in the list to have either a " 0 " or " 1 " appended. A" "0" is appended to the name if the ASCll decimal sum is even, otherwise a " 1 " is appended. - function count oddEven which, given a list of names with "0" or " 1 " at the end of each name, counts and prints the number of Jupians in each of the odd and even groups. - function main which, creates a list of names of at least 10 Jupians, uses the updatelist function to change the contents of that list appropriately to a list of names with " 0 " or " 1 " at the end of each name, prints the new list, and finally, uses the countoddEven function to display the numbers of Jupians in each of the odd and even groups. Note: You may include the list of names directly in your code, or you may ask the user to enter the names and append them to a list. Your code should work for any (non-empty) sized list, not just a list of 10 Juplans. For example, given a list such as: \[ \begin{array}{r} \text { jupians = ["Zubajup", "Bubajup", "Pubajup", "qubajup", "Rubajup", } \\ \text { "Subajup", "Tubajup", "Uubajup", "Qubajup", "Nubajup"] } \end{array} \] Sample output would be: ['zubajup1', 'Bubajup1', 'Pubajup1', 'Yubajupo', 'Rubajup1', 'Subajupo', 'Tubajup 1', 'vubajupo',' 'Qubajupo', 'Nubajup1'] There are 4 Jupians in the even group. There are 6 Jupians in the odd group.


We have an Answer from Expert

View Expert Answer

Expert Answer


Hey there! The code is explained through python comments. Hope it helps :) the getSum() function: # function getSum which, given a name, obtains the s
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe