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%...

  • Python homework problem First: Write a program (using a loop with break) to allow a user...

    Python homework problem First: Write a program (using a loop with break) to allow a user to input an integer and determine if the integer is prime. Then change the program to examine a number of integers to determine if each is prime. The program should allow the user to input the number of integers (say n) to be checked to determine if each is prime. Then the user should input n integers and print whether each of the integers...

  • 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 Write a program to enter a valid variable till the user wants to end. The...

    PYTHON Write a program to enter a valid variable till the user wants to end. The program should display the count of positive, negative, zeros and letters (upper and lower case)/symbols (error handling) entered. Based on the problem, you need to design an algorithm as follows: 1. Get the user input until “n” is entered 2. Add to the positive if it is greater than zero 3. Add to the negative if it is less than zero 4. Add to...

  • (COs 1 and 8) Create a Python program that calculates the tip and total for a...

    (COs 1 and 8) Create a Python program that calculates the tip and total for a meal at a restaurant. Paste Python code here; output not required. Sample output: Tip Calculator Enter cost of meal: 52.31 Enter tip percent: 20 Tip amount: 10.46 Total amount: 62.77 Specifications: •Input: costOfMeal, tipPercent         The formula for calculating the tip amount is: tip = costOfMeal * (tipPercent / 100) •         The program should accept decimal entries like 52.31 and 15.5. •         Assume the user...

  • Write a Python program that converts an input file in FASTA format, called "fasta.txt", to an...

    Write a Python program that converts an input file in FASTA format, called "fasta.txt", to an output file in PHYLIP format called "phylip.txt". For example, if the input file contains: >human ACCGTTATAC CGATCTCGCA >chimp ACGGTTATAC CGTACGATCG >monkey ACCTCTATAC CGATCGATCC >gorilla ATCTATATAC CGATCGATCG Then the output file should be human ACCGTTATACCGATCTCGCA chimp ACGGTTATACCGTACGATCG monkey ACCTCTATACCGATCGATCC gorilla ATCTATATACCGATCGATCG FASTA format has a description (indicated with a '>') followed by 1 or more lines of a DNA sequence. PHYLIP format has a description...

  • Write a program in C++ that reads in integer numbers from a file called scores.txt until...

    Write a program in C++ that reads in integer numbers from a file called scores.txt until the sentinel value -999 is read. The program should then output the total and average of the numbers read and output each of the numbers incremented by the overall average to a file called or scoresout.txt along with the sentinel value of -999 at the end So if 10, 20, 30 and -999 are read in then the program would display a total 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...

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