Question

Write, test and document a Python program, in a file called MarsCoins.py, to solve the following problem Marvin from Mars has

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hopefully all yours doubt will clear if you have left with any doubt please let me know in comment. I will try my best to resolve that.

Here i am posting code and screenshot of program so that you have a clear idea about indentation and output with it.

Code :-

# enter the different currency and friends
maruvians = int(input("Please enter the number of Maruvians: "))
caruvians = int(input("Please enter the number of Caruvians: "))
taruvians = int(input("Please enter the number of Taruvians: "))
paruvians = int(input("Please enter the number of Paruvians: "))
friends = int(input("Please enter the number of friends: "))

# compute number of paruvians by converting all currency into it
paruvians = maruvians*24 + taruvians*6+ caruvians*12 + paruvians

# Compute total number of maruvians
maruvians = paruvians // 24
# compute paruvians left that will be put back in jar
paruvians = paruvians % 24
# print total number of maruvians
print("Marvin has %d Maruvian(s) in total." %maruvians)
# compute the distributed maruvians
give = maruvians//(friends+1)
#print the distributed maruvians
print("He gives %d Maruvian(s) to himself and to each of his %d friends " %(give ,friends))
# compute the maruvians left that will be put back in jar
maruvians = maruvians % (friends+1)
# print maruvians and paruvians left that will be put back in jar
print("Marvin puts back %d Maruvian(s) and %d Paruvian(s) back in the jar."%(maruvians ,paruvians))

Screenshot of program :-

untitled [DA\untitled]-..day \ch15.py [untitled] - PyCharm Eile Edit View Navigate Code Refactor Run Iools VCS Window Help ch

Screenshot of output :-

untitled [DA\untitled]-..day \ch15.py [untitled] - PyCharm Eile Edit View Navigate Code Refactor Run Iools VCS Window Help ch

Add a comment
Know the answer?
Add Answer to:
Write, test and document a Python program, in a file called MarsCoins.py, to solve the following problem Marvin from Ma...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in python that asks the user to input a sentence. The program will...

    Write a program in python that asks the user to input a sentence. The program will ask the user what two letters are to be counted. You must use a “for” loop to go through the sentence & count how many times the chosen letter appears in the sentence. You are not allowed to use python built-in function "count()" or you'll get a Zero! Output will show the sentence, the letter, and the number of times the letter appears in...

  • 2. In a file called passfail.py, write a Python program to solve the following problem: Given...

    2. In a file called passfail.py, write a Python program to solve the following problem: Given a file students.txt with the following information for a stu dent: student number, average quiz mark, average assignment mark, midterm exam mark, and final exam mark (where each mark is recorded out of 100), de termine if the student has passed or failed based on the following information A student will pass the course if they have a passing mark (50% or higher) for...

  • python question 2. In a file called passfail.py, write a Python program to solve the following...

    python question 2. In a file called passfail.py, write a Python program to solve the following problem: Given a file students.txt with the following information for a stu dent: student number, average quiz mark, average assignment mark, midterm exam mark, and final exam mark (where each mark is recorded out of 100), de termine if the student has passed or failed based on the following information: • A student will pass the course if they have a passing mark (50%...

  • 1. Write a Python program, in a file called concat_strings.py, that includes the following functions: orderedConcat,...

    1. Write a Python program, in a file called concat_strings.py, that includes the following functions: orderedConcat, a recursive function that takes two alphabetically-ordered strings and merges them, leaving the letters in alphabetical order. Note that the strings may be different lengths. a main method that inputs two ordered strings and calls the orderedConcat method to return a resulting merged, ordered string. Your main method should print the two input strings and the result. Note: You may not use any of...

  • Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number...

    Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...

  • PYTHON CODE First Code: Write a program that uses a text file to store the daysand...

    PYTHON CODE First Code: Write a program that uses a text file to store the daysand hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line. Sample Output (inputs shown in boldface) How many days did you work this week? 5 Enter...

  • In python, write the following program, high school question, please keep simple. When I submitted the...

    In python, write the following program, high school question, please keep simple. When I submitted the solution, I get an error as 'wrong answer'. Please note below the question and then the solution with compiler errors. 7.2 Code Practice: Question 2 Instructions Write a program to generate passwords. The program should ask the user for a phrase and number, and then create the password based on our special algorithm. The algorithm to create the password is as follows: If the...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the guard....

  • use Python and please comments every step. [25] 6. Write a program that reads from standard...

    use Python and please comments every step. [25] 6. Write a program that reads from standard input, two times in military format and prints the number of hours and minutes between the two times. Assume that the second time is always ahead of the first time. You should avoid using conditional statement (if-else) for this program. Your program must query the user for the two times and output the difference based on the two sample runs given below. Please enter...

  • Write a Python program to solve the following problem: Information is available about the latest municipal election. For...

    Write a Python program to solve the following problem: Information is available about the latest municipal election. For each voter, the following data is given: voter id number age of voter the ward number (1, 2, 3 or 4) in which the voter resides the name of the person the voter selected for mayor Input this information and compute and output the following statistics: the total number of voters the number of people under the age of 25 who voted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT