Question

Python #IMPORTANT! Instructions in each section are cumulative. The later format specifiers should include previous formats...

Python

#IMPORTANT! Instructions in each section are cumulative. The later format specifiers should include previous formats
#withing each section

#Section 1
#Assign the number 1234567 to a variable
#Convert the number to a float
#Display the number
#Note: Assign each of the following formatted outputs to new variable names
#Now format the number with a dollar sign to its left and two decimal places using a format specifier
#Display the number as formatted in the previous line
#Change the number's format to display four decimal places
#Display the number as formatted in the previous line
#Change the number's format to display NTD and a space to its left
#Display the number as formatted in the previous line

#Section 2
#Assign the number 30004000.6735 to a variable
#Convert the number to a float
#Display the number
#Note: Assign each of the following formatted outputs to new variable names
#Now format the number with HK$ and a space to its left and three decimal places using a format specifier
#Display the number as formatted in the previous line
#Change the number's format to display one decimal place
#Display the number as formatted in the previous line
#Change the number's format to display AUS$ and a space to its left
#Display the number as formatted in the previous line

#Section 3
#Ask the user for a number and assign it to a variable
#Convert the number to a float
#Display the number
#Note: Assign each of the following formatted outputs to new variable names
#Now format the number with $ and a space to its left and two decimal places using a format specifier
#Display the number as formatted in the previous line
#Change the number's format to display three decimal place
#Display the number as formatted in the previous line
#Change the number's format to display JPY and a space to its left
#Display the number as formatted in the previous line

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

Section 1

var1 = 1234567

var1 = float(1234567)

print(var1)

p1 = "$%.2f" %(var1)

print(p1)

p2 = "%.4f" %(var1)

print(p2)

p3 = "NTD %f" %(var1)

print(p3)

Section 2

var2 = 30004000.6735

var2 = float(30004000.6735)

print(var2)

p1 = "HK$ %.3f" %(var2)

print(p1)

p2 = "HK$ %.1f" %(var2)

print(p2)

p3 = "AUS$ %f" %(var2)

print(p3)

Section 3

num = float(input("Enter a number: "))

print(num)

p1 = "$ %.2f" %(num)

print(p1)

p2 = "%.3f" %(num)

print(p2)

p3 = "JPY %f" %(num)

print(p3)

Add a comment
Know the answer?
Add Answer to:
Python #IMPORTANT! Instructions in each section are cumulative. The later format specifiers should include previous formats...
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
  • For Python-3 I need help with First creating a text file named "items.txt" that has the...

    For Python-3 I need help with First creating a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots. Write a python program that 1. Puts this as the first line... import os 2. Creates an empty list 3. Defines main() function that performs the tasks listed below when called. 4. Put these two lines at the top of the main function... if os.path.exists("costlist.txt"): os.remove("costlist.txt") Note: This removes the "costlist.txt" file, if it exists. 5....

  • Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also...

    Written in python using puTTy!! i'm having a lot of trouble with this, will upvote! also here is the address.csv file Name,Phone,Email,Year_of_Birth Elizi Moe,5208534566,[email protected],1978 Ma Ta,4345667345,[email protected],1988 Diana Cheng,5203456789,[email protected],1970 ACTIVITY I Implement in Python the Subscriber class modeled by the UML diagram provided below. Save in a file called MyClasses.py Subscriber name: string yearOfBirth: int phone: string email: string getName() getAge() getPhone() getEmail() Write a test program that does the following: Read the file addresses.csv. For each record, create an object...

  • CT143 : Intro to C++ Lab 15: Array Practice Instructions Complete each of the C++ activities...

    CT143 : Intro to C++ Lab 15: Array Practice Instructions Complete each of the C++ activities described below in a single source file Label each activity with its own heading using comments. Activities: 1) Favorite numbers a. Declare and initialize an array of 10 integers as a single statement using a name of your choice. b. Output the result of adding the 1st and 5th members of the array. C. Subtract the 4h member from 3 times the 10th member...

  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

  • Write a C program to compute average grades for a course. The course records are in...

    Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...

  • Please help program in python read all instructions 2.13 LAB*: Program: Cooking measurement converter Output each...

    Please help program in python read all instructions 2.13 LAB*: Program: Cooking measurement converter Output each floating point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value) (1) Prompt the user for the number of cups of lemon juice, water, and agave nectar needed to make lemonade. Prompt the user to specify the number of servings the recipe yields. Output the ingredients and serving size. (Submit for 2 points) Note: This zyLab outputs a...

  • %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should...

    %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should be a positive number) ◦ the annual interest rate (should be a float between 0 and 1) ◦ the term of the mortgage, in years (should be a positive integer; default value: 30) ◦ the number of payments per year (should be a positive integer; default value: 12) • Functionality ◦ Compute the minimum mortgage payment. Should use the formula A= Pr(1+r) n (1+r)...

  • In C++ Rewrite Modularity section to clarify functions should be separate. Assignment 6 - Monkey Food...

    In C++ Rewrite Modularity section to clarify functions should be separate. Assignment 6 - Monkey Food In the Gaddis textbook read Chapter 8 sections 8.1-8.9 before starting this assignment. This assignment is Programming Challenge 4 from Chapter 8 of the textbook. A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 7 arrray,...

  • GENERAL INSTRUCTIONS              All requirements specified on page 64-67 of the course packet “2.5 Programming Assignment...

    GENERAL INSTRUCTIONS              All requirements specified on page 64-67 of the course packet “2.5 Programming Assignment Submission Requirements” and “2.6 Flow Chart Symbols” should be followed.              Plan the programs on paper before you attempt to write any programs (it will take less time to complete the assignment overall).              Electronic version of your programs (the .m files you create) must be uploaded to Canvas. Attach multiple files to one submission. All files must be received by the beginning of...

  • A company has received an order to manufacture 75 customized units of an entertainment cabinet. The...

    A company has received an order to manufacture 75 customized units of an entertainment cabinet. The company is being offered $960 per cabinet and the CEO must decide whether or not to accept the order. An analysis of the production process for the cabinet reveals that a new, special-purpose lathe will be required. The estimated cost of the lathe is $14,400, although there is some uncertainty due to new tariffs. The variable cost is more difficult to estimate because 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