首页 新闻 聚焦 科技 财经 创业 综合 图片 视频

IT界

旗下栏目: 行业 生态 IT界 创新

代写CS‐521程序实验、python代写

来源:互联网 发布时间:2021-05-06
代写CS‐521程序实验、python代写
CS‐521 Homework Assignment 6
1
Assignment Directions
The specific instructions for these programming exercises are adapted from problems shown in the
textbook.  Make sure to follow the specific instructions in THIS document.  
Each program is worth 50 points for a total of 100 points (100%).
Style Requirements
For all assignments, Follow the guidelines in the PEP8 Standards and Best Practices that have been
shared to date, along with course specific requirements. Minor deductions will occur for:
 Improper naming of programs or zip container
o Among other things, names for regular programs and zip file must be all lower case
and class file names are CamelCase.
 Missing program docstring
 Inadequate # line comments (just a few in each program, don’t go crazy)
 Going significantly over 80 characters for code/comment lines
 Not naming objects appropriately
o variables and functions must use snake_case (lower case plus underscores)
o CONSTANT variables in all upper case
o Class Objects, which are taught in module 6, as CamelCase
 Asking for input() without descriptive prompts telling the user what is expected.
o Especially not mentioning the delimiter when input will be split()
 Printing output that is not clearly explained (where necessary)
 Not providing a docstrings for functions and class objects
 Crashing uncontrolled on bad user input
 Having too large a scope for try blocks
 Not using format() to round output and add thousand separating commas (US standards)
o 123456.126  should be 123,456.13  '{:,.2f}'.format(123456.126)
 Having a “main()” function, with no input arguments or return values
 Not using an if __Name__ == '__main__' block where appropriate
   
CS‐521 Homework Assignment 6
2
Chapter 11 Exercise
6.11.1:  Write a python program using the following requirements:
Create a class called Sentence which
 has a constructor that takes a sentence string as input.
o The default value for the constructor should be an empty string
o The sentence must be a private attribute in the class
 contains the following class methods:
o get_all_words — Returns all the words in the sentence as a list
o get_word — Returns only the word at a particular index in the sentence
 Arguments: index
o set_word — Changes the Word at a given index in sentence to a new word
 Arguments: index, new_word  
 Does not return anything
o a str method — Returns the sentence as a string using the built‐in method
Include a unit test in an if __name__ block to test the class. Use assert to check for errors.
Hint: The problem might be easier to code if sentence attribute is a list of the words, where
punctuation has already been parsed out.
Unit Test Template:
1. Set a sentence variable with a sentence of your choice
2. Instantiate the Sentence object using the variable  
3. Test that get_all_words() correctly returns that sentence as a list
4. Test that get_word(#) correctly returns the # word in the sentence
5. Test that set_word() actually changes a word in the sentence object
6. Print the sentence before and after the word change using the built in str method
   
CS‐521 Homework Assignment 6
3
Chapter 12 Exercise
6.12.2 Write a python program using the following requirements:
The human body has Many organs. These organs have some properties in common and
others that are specialized.
 Create an Organ class as a base class for specific organs
o Attributes for the organ class are:  
 organ_name
 organ_weight_grams
 is_vital_organ
 organ_system
 is_transplantable
 organ_gender
o Required reserved methods for organ class:
 Constructor  
 Repr method that returns the attributes of organ instance
 Create a Heart class as a child of the organ class
o The heart is a vital organ in the Muscular system
o Attributes for heart, defined in the constructor, are:  
 heart_length_cm
 heart_weight_grams (use the parent class)
 heart_thickness_cm
 heart_breadth_cm
o Required reserved methods for heart class:
 Constructor  
 Repr method That returns the attributes of heart instance
o Required general methods for heart class:
 heart_status – returns ‘Pumping blood’
 heart_weight_oz – returns the heart weight in ounces
 1 gram = 0.035 ounces
<Continued next page>
   
CS‐521 Homework Assignment 6
4
6.12.2 continued…
 Create a Brain Class as a child of the organ class
o The brain is a vital organ in the Nervous system
o Attributes for brain, defined in the constructor, are:  
 brain_volume (in centimeters)
 brain_weight_gram (use the parent class)
o Required reserved methods for brain class:
 Constructor  
 Repr method that returns the attributes of brain instance
o Required general methods for brain class:
 brain_status – returns ‘Thinking’
 brain_weight_oz – returns the brain weight in ounces
 1 gram = 0.035 oz
Include a unit test in an if __name__ block to test the class. Use assert to check for errors.
Unit Test Template:
 Instantiate the heart Object with attributes 12, 280, 6.0, 9.0
 Instantiate the brain object with attributes 1260, 1370.0
 Test that all the parent and child attributes match what was instantiated
 Test that the general methods return the appropriate values
Where to submit?  
Click Assignments in the Navigation Area and then click on the title of the assignment to enter the
submission area and Upload the zip file with your response.
 
请加QQ:99515681 或邮箱:99515681@qq.com   WX:codehelp
  免责声明:珠穆朗玛网对于有关本网站的任何内容、信息或广告,不声明或保证其正确性或可靠性,用户自行承担使用网站信息发布内容的真假风险。
责任编辑:珠穆朗玛网