Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python programming Question: Starter code: Somethings to help: Thank you so much! Question: Write a Python function, compound properties O, that is passed a file

Python programming
Question: image text in transcribed
Starter code:
image text in transcribed
image text in transcribed
Somethings to help:
image text in transcribed
image text in transcribed
image text in transcribed
Thank you so much!
Question: Write a Python function, compound properties O, that is passed a file name of a CSV file (assume the file is in the same folder as your Python file) and a compound's formula unit structure. The file will contain metal elements and their properties. In the function, you are tasked to read the compound formulation (by the molformO function described below), find out properties of those constituent in the compound in the CSV file, and return a tuple of 1. The element in the compound with the lowest boiling point (full name, like Hydrogen' for 'H) 2. The average boiling point of all elements, round to the nearest integer 3. The molecular mass of that compound (the atomic mass of each element, multiplied by the number of atoms in the molecule), round to the nearest integer For example, >>> compound properties (input.csv. 'Fe1s104') FeSO ('Oxygen',477, 152) Write a second function, molform, that will be called by the first function, to take the compound's formula and return it as a dictionary with the elements as the keys and the number of atoms as the values. Note that, you can assume element names won't exceed two letters in length, but the number of atoms might be huge, for example, CH21sNOSws (in case you wonder, this thing does exist, it's called a Titin', a very important protein in muscle fibers. Pronouncing the full name of it will take you a good four hours time. You may assume the compound structure will specify the number of atoms, even if the IUPAC formula would omit the subscript 1. For instance, ethanol, CH.O, would be passed to the program as the string "C2H601 Your function must read files with the format of atoms.csv. Each new column of data is separated by a comma (CSV). Don't be scared off by this long file, every line has the same format. You can test your function using a subset of the file atoms.csv (create the subset by removing many lines from it). Testcases to understand the inputs and outputs of each function can be found on the next page. TO DO: Download the file 1ab6.py, complete the functions inside according to their descriptions and upload your version of lab6.py to MarkUs. Do not change the file name or function names Do not use input) or print0. Your file should not contain any additional lines ef code outside the function definitions. Some test cases are included in the docstrings. def compound properties (csv_name, compound formula): "" " (str, str) -> tuple This function takes two parameters: the csv filename and the formula of the compound. It should call the molform) function to get the composition of the molecule and get the required property from the csv file. properties required. This function is required to return a tuple 1. The NAME of the atom with the lowest The csv file will have all the of three properties: boiling point. For example, if it's oxygen, return Oxygen, not 'o 2. The average (mean) of the atoms' boiling point in the molecule, round to the nearest integer For example, for Feso4, it's the average do not multiply the boiling point by the 3. The molecular mass of the compound, round boiling point of Fe, S and O, number of the atoms to the nearest integer weight of 12+1+16*2-44 For example, C102 (carbon dioxide) has def molform(compoundformula): "" " (str) -> dictionary formula, returns a dictionary atoms of that element as values. dictionary When passed a string of the compound with the elements as keys and the number of When the string is empty, return an empty >>> molform( "C2H601") >>>molform("Cr1H4" def molform(compound formula): formula, returns a dictionary atoms of that element as values dictionary " "" (str) -> dictionary When passed a string of the compound with the elements as keys and the number of When the string is empty, return an empty >>> molform(" C2H601") >>> molform("Cr1H4" ) molform ( "132983H2 1 1 86 1N361490408835693" ) 'C 132983, 'H 211861, 'N: 36149, '0: 40883, 'S': 693) atomicMass boilingPoint HHydrogen .0079420 HeHelium .002602 4 Lithium 6.941 Be Beryllium 9.012182 2743 8 Boron Carbon 10.811 2.0107 4300 14.006777 15.9994 90 18.9984032 8S 20.1797 27 22.98976928 1156 4273 N Nitrogen Oxygen F Fluorine Ne Neon Na Sodium Mg Magnesium24.305 A Alluminum26 9815386 2792 Si Silcon 55 3173 Phosphorus 30 973762 554 Sulfur Chlorine Argon K Potassium Ca Calcium Sc Scandium 44955912 3103 239 39.0983 1032 40.078 Ti Tanium 47 867 VVanadium S0.9415 3680 Cr Chromium 1.9961 Mn Manganese 54.9380452334 Fe Iron Co Cobalt N Nickel Cu Copper Zn Zinc Ga Gallium Ge Germanium 72.64 As Arsenic Se um 96 Br Bromine Kr Krypton Rb Rubidium 85 4678961 Sr Strontium 7 62 58.933195 3200 3186 1180 4.9216 887 958 Yttrium Zirconium 91.224 88.905853618 4423 cacao 112411 540 Dn Idium 7275 La Lanhanm 38 90547 3737 40 11633 5925353503 267259 3341 Tm Thm6 93421 2223 Bdum7 4701 Pt Platinum504 4098 966569 3129 22) Americium 243 2284 95 Am Curium 247 3383 96 Cm

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_2

Step: 3

blur-text-image_3

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

3 > O Actual direct-labour hours Standard direct-labour hours...

Answered: 1 week ago

Question

What is the submission deadline for the final report?

Answered: 1 week ago

Question

What is the indicative word limit?

Answered: 1 week ago