Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python Every character has a number associated with it in ASCII. A capital A is 65. A capital B is 66. A lower-case z

Using Python

Every character has a number associated with it in ASCII. A capital "A" is 65. A capital "B" is 66. A lower-case "z" is 122. A percent sign "%" is 37.

You can find the number associated with a character using the ord() function. For example, ord("A") will return 65. ord("Z") will return 90.

You can use this to find the number of characters between two letters. For example, ord("R") - ord("D") is 14, meaning there are 14 letters between D and R.

Capital letters are numbered 65 through 90. Lower-case letters are numbered 97 through 122. Numerals are numbered 48 through 57. Reserved system characters are numbered 0 through 31, while the remaining numbers below 127 (32 to 47; 58 to 64; 91 to 96; and 123 to 128) are punctuation marks.

cut = "Emerald" clarity = "VS" color = "E" carat = 1.1 budget = 500 preferred_cuts = ["Emerald", "Cushion", "Princess", "Oval"]

#You may modify the lines of code above, but don't move them! #When you Submit your code, we'll change these lines to #assign different values to the variables.

#Diamonds are typically evaluated according to four aspects: # - Cut: The way the diamond is cut # - Clarity: How clear or flawless the diamond is, rated # as F (the best), IF, VVS, VS, SI, or I (the worst) # - Color: How colorless the diamond is, rated from "D" (the # best) to "Z" (the worst) # - Carat: How large the diamond is, weighed in carats # #Cut is usually a matter of personal preference. Clarity, #color, and carat are matters of value: the clearer, more #colorless, and larger a diamond is, the greater its value. # #Imagine you're shopping for a diamond. You have your #preferred cuts, and you have a budget in mind. You're shown #a diamond whose characteristics are represented by the cut, #color, clarity, and carat variables above. You'll buy the #diamond if its cost is less than your budget, and if its #cut is one of your preferred cuts. # #At this store, every diamond has a base cost of 100. # #For every color rating worse than "D", the cost decreases by #2%. An "F" color diamond would be worth 0.96 * the diamond #cost otherwise because "F" is two colors worse than "D". # #A diamond's value is doubled for every level of clarity above #I. A "VVS"-clarity diamond is worth 8 * the diamond cost #otherwise because "VVS" is three levels higher than I, and #doubling its value three times raises its value by 8x total. # #After finding its price based on color and clarity, its price #is multiplied by its weight in carats. # #Your program should print "I'll take it!" if you will buy the #diamond, "No thanks" if you will not. To purchase it, its price #must be less than your budget and its cut must be one of your #preferred cuts. # #HINT: You can find the number of characters between two #characters by using the ord() function. ord("E") - ord("D") #is 1; ord("Z") - ord("D") is 22. #Add your code here!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions