Question

Question 1. Study the examples below carefully and write a program for journal subscription Your program should work exactlySubscribe to Journal of Commodity Markets? (Y/N):N Subscribe to Journal of Sustainable Mining? (Y/N) N Subscribe to Journal oImportant requirements: . On the top, the program must use string format to display the journal price. The 1st column must haQuestion 2. A. Write a program using for loop to display the following exact output Question 2A: - 1 B. Write a program usingQuestion 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 length

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 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
Subscribe to Journal of Commodity Markets? (Y/N):N Subscribe to Journal of Sustainable Mining? (Y/N) N Subscribe to Journal of Asia-Pacific Biodiversity? (Y/N): Y Your selection: - Journal of Asia-Pacific Biodiversity Total cost $75 Example 3: The user is a student, and the user subscribes to no 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): N Subscribe to Journal of Sustainable Mining? (Y/N): N Subscribe to Journal of Asia-Pacific Biodiversity? (Y/N):N Your selection: -None Total cost $0
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 2. A. Write a program using for loop to display the following exact output Question 2A: - 1 B. Write a program using while loop to display the following exact output -Question 2B: --
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 ㄊㄊㄊㄊㄊ
0 0
Add a comment Improve this question Transcribed image text
Answer #1

python code for question1

##################################################

import pandas as pd   
data = [['Journal of Commodity Markets', '$21', '$50'],['Journal of Sustainable Mining', '$22', '$60'],['Journal of Asia-Pacific Biodiversity', '$27', '$75']] # data for table
df = pd.DataFrame(data) # converting data into dataframe
df.columns = ['Journals', 'Student', 'Non-student'] # inserting columns name into dataframe

print(df)

option1 = input("Are you a student?")
option2 = input("subscribe to Journal of Commodity Markets? (Y/N): ")
option3 = input("subscribe to Journal of Sustainable Mining? (Y/N): ")
option4 = input("subscribe to Journal of Asia-Pacific Biodiversity? (Y/N): ")

print("Your selection:")
if option2 == 'Y':
print(" - Journal of Commodity Markets")
if option3 == 'Y':
print(" - Journal of Sustainable Mining")
if option4 == 'Y':
print(" - Journal of Asia-Pacific Biodiversity")
if option2 == 'N' and option3 == 'N' and option4 == 'N':
print(" - None")
  
cost = 0 # cost variable is initialized to 0 and is updated furthur according to journals choosen
if option1 == 'Y':
if option2 == 'Y':
cost += 21
if option3 == 'Y':
cost += 22
if option4 == 'Y':
cost += 27
else:
if option2 == 'Y':
cost += 50
if option3 == 'Y':
cost += 60
if option4 == 'Y':
cost += 75
print("Total Cost $",cost)

#############################################

output:

                               Journals Student Non-student
0          Journal of Commodity Markets     $21         $50
1         Journal of Sustainable Mining     $22         $60
2  Journal of Asia-Pacific Biodiversity     $27         $75
Are you a student?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
Are you a student?N
subscribe to Journal of Commodity Markets? (Y/N): N
subscribe to Journal of Sustainable Mining? (Y/N): N
subscribe to Journal of Asia-Pacific Biodiversity? (Y/N): Y
Your selection:
 - Journal of Asia-Pacific Biodiversity
Total Cost $ 75
Are you a student?Y
subscribe to Journal of Commodity Markets? (Y/N): N
subscribe to Journal of Sustainable Mining? (Y/N): N
subscribe to Journal of Asia-Pacific Biodiversity? (Y/N): N
Your selection:
 - None
Total Cost $ 0
Add a comment
Know the answer?
Add Answer to:
Only use the code in Objectives and write the code in Python
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 the code in Python. The output should be exact the same as the given.

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

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

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

  • In Jgrasp(Java) Thanks! This solution must use methods. It is recommended to use methods for this...

    In Jgrasp(Java) Thanks! This solution must use methods. It is recommended to use methods for this solution. Write a program that reads an integer and displays, using asterisks, a filled and hollow square, placed next to each other. For example, if the side length is 5. the program should display: ***** ***** You can assume that the user will enter a side length that is at least 2. If user enters a number smaller than 2, and your program has...

  • Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the...

    Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the Area of a Circle 2.       Calculate the Area of a Triangle 3.     Calculate the Area of a Rectangle 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. Use the formula:      area = ∏r2    Use 3.14159 for ∏. If the user enters 2 the program should ask for...

  • Problem 1 Write a Python program to do the following: (A) Ask the user to enter...

    Problem 1 Write a Python program to do the following: (A) Ask the user to enter as many integers from 1 to 10 as he/she wants. Store the integers entered by the user in a list. Every time after the user has entered an integer, use a yes/no type question to ask whether he/she wants to enter another one. (B) Display the list. (C) Calculate and display the average of the integers in the list. (D) If the average is...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is sued. Write a Python code that gets a string containing a person’s first, middle, and last name, and print her/his last name, followed by comma and the first name initial. For example, if the user enters Randy Rick Gomez, the program should display Gomez, R. Please note that in the output, the first character of each name should be capital. Please see the outcomes below: Outcome: Enter your...

  • Geometric calclator use python to do this program. Write a program that displays the following menu:...

    Geometric calclator use python to do this program. Write a program that displays the following menu: 1. Calculate the area of circle 2. calculate the area of rectangle 3. calculate the area of triangle 4. Quit Enter your choice (1-4). if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area: Area = pi*r^2 Use 3.14149 for Pi and the radius of the...

  • Write a Python program to prompt the user for an integer number. Assign this integer to...

    Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...

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