Question

Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactlyImportant requirements: . On the top, the program must use string format to display the journal price. The 1st column must haQuestion 3. Study the examples below carefully and write a program to ask the user to enter the length of the square and thenExample 2: The user chooses the square length to be 2 --Question 3: -- Enter the length of square: 2 Here is a square of lengExample 5: The user chooses the square length to be 5 -Question 3: - Enter the length of square: 5 Here is a square of lengthObjectives Able to write clear code with comments and follow coding convention Able to use variables Able to use string forma

Write the code in Python. The output should be exact the same as the given.

Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50 $60 $75 Are you a student? (Y/N): Y Subscribe to Journal of Commodity Markets? (Y/N): Y Subscribe to Journal of Sustainable Mining? (Y/N): N Subscribe to Journal of Asia-Pacific Biodiversity? (Y/N):Y Your selection: - Journal of Commodity Markets - Journal of Asia-Pacific Biodiversity Total cost $48 Example 2: The user is not a student, and the user subscribes to 1 journal Question 1: - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50 $60 $75 Are you a student? (Y/N):N

Important requirements: . On the top, the program must use string format to display the journal price. The 1st column must have left alignment with 40 spaces; the 2nd and 3rd columns must have right alignment with 15 spaces. . The program must display all the journals that the user has selected. When the user selects no journals then the program must display "None" as in the Example 3 above The total cost must be calculated correctly depending on the user is a student or non-student. For user input, we assume that the user always enter Y or N, and your program does not have to handle invalid input.
Question 3. Study the examples below carefully and write a program to ask the user to enter the length of the square and then display the square. Your program must use for loop statement. Your program should work exactly as the following examples. The text in bold indicates user input. Example 1: The user chooses the square length to be l -Question 3: - Enter the length of square: 1 Here is a square of length 1
Example 2: The user chooses the square length to be 2 --Question 3: -- Enter the length of square: 2 Here is a square of length 2 Example 3: The user chooses the square length to be 3 -Question 3: -- Enter the length of square: 3 Here is a square of length 3 Example 4: The user chooses the square length to be 4 -Question 3: - Enter the length of square: 4 Here is a square of length 4
Example 5: The user chooses the square length to be 5 -Question 3: - Enter the length of square: 5 Here is a square of length 5 ㄊㄊㄊㄊㄊ
Objectives Able to write clear code with comments and follow coding convention Able to use variables Able to use string format Able to get user input and display output Able to translate number into string and string into number Able to use if-else statements Able to use loop statements . *
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#we are supposed to answer 1 question at a time
#please ask the remaining again
print('--- Question 1: ----')
print('{:<40s}{:>15s}{:>15s}'.format(' ', 'Student', 'Non-student'))
print('{:<40s}{:>15s}{:>15s}'.format('Journal of Commodity Markets', '$21', '$50'))
print('{:<40s}{:>15s}{:>15s}'.format('Journal of Sustainable Mining', '$22', '$60'))
print('{:<40s}{:>15s}{:>15s}'.format('Journal of Asia-Pacific Biodiversity', '$27', '$75'))

student = input('\nAre you a student? (Y/N): ')

j1 = input('\nSubscribe to Journal of Commodity Markets? (Y/N): ')
j2 = input('Subscribe to Journal of Sustainable Mining? (Y/N): ')
j3 = input('Subscribe to Journal of Asia-Pacific Biodiversity? (Y/N): ')
cost = 0
print('\nYour selection:')
if j1 == 'Y':
    print(' - Journal of Commodity Markets')
    cost += (student == 'Y') * 21 + (student == 'N') * 50
if j2 == 'Y':
    print(' - Journal of Sustainable Mining')
    cost += (student == 'Y') * 22 + (student == 'N') * 60
if j3 == 'Y':
    print(' - Journal of Asia-Pacific Biodiversity')
    cost += (student == 'Y') * 27 + (student == 'N') * 75

if j1 == 'N' and j2 == 'N' and j3 == 'N':
    print(' - None')

print('\nTotal cost ${:d}'.format(cost))

Question 1: Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $

Add a comment
Know the answer?
Add Answer to:
Write the code in Python. The output should be exact the same as the given.
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
  • Only use the code in Objectives and write the code in Python

    Only use the code in Objectives and write the code in Python Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactly as the following examples The text in bold indicates user input. Example 1: The user is a student, and the user subscribes to 2 journals Question 1 - Journal of Commodity Markets Journal of Sustainable Mining Journal of Asia-Pacific Biodiversity Student $21 $22 $27 Non-student $50 $60 $75 Are...

  • Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a scr...

    Write the code in python, if you cannot answer all the question please dont anser, thanx very much. Please gimme a screen shot for code. Write clear code with comments and follow coding convention. Comments should include your name, student number and subject code on top of your code Question 1 Create a list to store all the subject codes that you are currently doing at UOW Then use for loop to display it in a table as in the...

  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • I need to write a paint job estimator program in python. I have most of it...

    I need to write a paint job estimator program in python. I have most of it down but i keep getting errors and I dont know how to fix it or what im doing worng specs: A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter...

  • python Topics covered: Using variables e Arithmetic operators Printing output Manipulating string objects . Generating random...

    python Topics covered: Using variables e Arithmetic operators Printing output Manipulating string objects . Generating random numbers . Getting user input NOTE: Each of your files must include a docstring at the top of the file containing your name, username, ID number and a description of the program. When solving these questions you must only use content covered in lectures 1 to 6 Submit the files containing your exercises using the Assignment Dropbox https:/adb auckland.ac.nz/Homel QUESTION 1 (3 MARKS) A...

  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate...

    Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...

  • Write a code using python that simulates a Registration of a Username and Password with the...

    Write a code using python that simulates a Registration of a Username and Password with the following conditions the user can set its username display "Input username" input Username display "Input Password" input Password The password must be at least 5 characters and no longer than 10 characters if the password doesn't follow this instructions Display "Can't accept this password" once the password its stored Verify that the program works by Testing it input username Input Password The user has...

  • Python Program For this program the user should be able to enter multiple sequences of X,...

    Python Program For this program the user should be able to enter multiple sequences of X, Y, and Z characters. The sequences should all be the same length. This program should output the average number and median number of X, Y, and Z characters for the set of sequences. Example. Input: XYYZ XYYZ ZZZX Output: Average number of Xs: 1 Average number of Ys: 1.33 Average number of Zs: 1.66 Median number of Xs: 1 Median number of Ys: 2...

  • PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a...

    PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a Python program that displays and describes the equation for plotting the sine function, then prompts the user for the values A, B, C and D to be used in the calculation. Your program should then compute and display the values for Amplitude, Range, Frequency, Phase and Offset. Example input/output for part 1: Part 2: Displaying a Vertical Plot Header A vertical plot of the...

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