CSIT 512 Hood College Chapter 10 Complex Sections of Code Programming Project • Use inline comments to describe complex sections of code Avoid unnecessary

CSIT 512 Hood College Chapter 10 Complex Sections of Code Programming Project • Use inline comments to describe complex sections of code Avoid unnecessary and trivial comments

BAD

Don't use plagiarized sources. Get Your Custom Essay on
CSIT 512 Hood College Chapter 10 Complex Sections of Code Programming Project • Use inline comments to describe complex sections of code Avoid unnecessary
Just from $13/Page
Order Essay

avg = (score1 + score2 + score3)/3 # add scores and divide by 3

ALMOST AS BAD – because well designed variable names should make the comment unnecessary

avg = (score1 + score2 + score3)/3 # calculate average

Whitespace and indentation:

• Use correct, consistent indentation.
o All blocks of code within a given function or control flow structure must be distinguished

from the preceding code by one indentation level.
o Use 4 spaces per indentation level. IDLE will automatically indent 4 spaces when you hit

the tab key.

Always place a line break after a colon ( : )
Avoid long lines.

o Avoid lines longer than 80 characters, including indentation. Make sure to maintain

correct indentation when breaking long lines into shorter ones.

Variables

Make smart variable type decisions and utilize type conversionsStore data using the appropriate data types (making sure to use the appropriate literals as well), and make sure to use the type conversion functions (str(), int(), float())when necessary. Remember, for example, that if you ask the user to input the temperature outside and you want to use that value in a calculation, you will have to convert their input to a float before you can use it.
Follow variable naming conventions
Name variables using underscore (AKA snake case) like_this. Use concise, descriptive namesfor variables that precisely describe what information they’re storing.
Create one variable per line of codeNever initialize more than one variable in a single statement.# bad # good a, b, c = 7, -43, 19 a = 7b = -43 c = 19

• Use named constants when appropriate

If a particular constant value is used frequently in your code, identify it as a constant, and always refer to the constant in the rest of your code rather than referring to the corresponding literal value. Name constants in uppercase with underscores between words LIKE_THIS.

DAYS_IN_WEEK = 7
DAYS_IN_YEAR = 365
HOURS_IN_DAY = 24

Part 2 – Conditionals and Loops
These requirements apply to Chapters 3 & 4 and later assignments

Control Statements

• Avoid empty if or else branches
o When using if/else statements, you should not have `if` or `else` branches that are blank.

Rephrase your condition to avoid this.

• Avoid unnecessary control flow checks

When using if/else statements, properly choose between various if and else patterns depending on whether the conditions are related to each other. Avoid redundant or unnecessary if tests. Ask yourself if all of the conditions always need to be checked.

# bad
if points >= 90:

print(‘You got Gold!’)
if points >= 70 and points < 90: print('You got Silver!') if points >= 50 and points < 70: print('You got Bronze!') ... # good if (points >= 90):

print(‘You got Gold!’)} elif points >= 70:

print(‘You got Silver!’) elif points >= 50:

print(‘You got Bronze!’)
…

Beware of infinite loops
Avoid writing loops that never stop. An infinite loop will cause your program to neverstop executing. Replace infinite loops with loops that terminate.
Choose the right loopConsider when it would be more appropriate to use a while loop or for item in list loop or for item in range loop.

Part 3 – Functions
These requirements apply to Chapter 5 and subsequent assignments

Use descriptive names for functionsGive functions descriptive names, such as discount(price, rate) or make_a_star(). Avoid one-letter names and non-descriptive names, like x() or go() or function1().Function names should be all lowercase, with words separated by underscores to improve readability.
Keep your main program a concise summaryAs much as possible, avoid having too much of your program’s functionality directly in your main() code. When writing your programs, try to break the problem down into smaller sub-problems. Create functions for these individual sub-problems. This makes your program easy to read and forms a concise summary of the overall behavior of the program.
Minimize redundant codeIf you repeat the same code block two or more times, find a way to remove the redundant code so that it appears only once. For example, you can place it into a function that is called from both places.
Avoid long functionsEach function should perform a single, clear, coherent task. If you have a single function that is very long or that is doing too much of the overall work, break it into smaller sub- functions. If you try to describe the function’s purpose and find yourself using the word “and” a lot, that probably means the function is doing too many things and should be split into sub-functions.
Consider short functions for common tasks
It can be useful to have a short function if it wraps another function with some additionalcontrol flow or if it contributes to an easier to understand name.# bad
def square_root(x):
return math.sqrt(x)

# good
def discount(price, rate):
discount = price – rate*price

return discount

Write an overall header comment for every function – use the IPO notation described in Chapter 5 slide 49

• Eliminate redundancy by introducing functions with parameters
If you repeat the same code two or more times that is nearly but not entirely the same, try

making a helper function that accepts a parameter to represent the differing part.

# bad

x = foo(10) y= x- 1 print(x * y) …

x = foo(15) y= x- 1 print(x * y)

# good

print(helper(10))
print(helper(15))
…

def helper(p):
x = foo(p)

y=x -1 return x * yx

Part 4 – Classes
These requirements apply to Chapter 10 and subsequent assignments

Do not access object attributes directly in the client (abstraction)You should avoid directly accessing attributes of classes you write. Instead, use getter and setter methods to access the appropriate pieces of information when necessary.
Keep related tasks bundled together within the appropriate class (encapsulation)You should design your classes in a such a way that all of the appropriate data and the methods that act upon that data are all encapsulated within the class. For example, the client of a graphics program should not be implementing its own graphical behavior or directly accessing graphical objects.
Avoid unnecessary instance variables (attributes)Use instance variables (attributes) only when they are required to implement certain functionality, or if it makes sense for that variable to persist outside of any given method. Don’t use them to store temporary values used in only a single call to one method, for instance. You should assess whether a variable is needed across multiple methods before making it an instance variable.

Focus on dictionary methods, use of functions, and good programming style

For this assignment, you will create a glossary (dictionary) of technical terms and definitions. It will be set up as a Python dictionary structure. The file assign08_starter.py is a complete starter framework for the assignment. It includes some initial values for the dictionary. IT is long because most of the code has already been written for you.

Your task is to complete the five individual functions for adding and deleting terms, looking up terms, listing them, and printing out both the terms and definitions. These functions are all short, just a couple of lines, and use basic dictionary methods and techniques.

Here is some sample output.

CSIT 512 Elements of Computer Programming Graded Programming Assignment 8

Notice that for 2 and 5, the terms are listed in alphabetical order. Also, lookup and delete should not be case sensitive.

Homework On Time
Calculate the Price of your PAPER Now
Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional academic writers

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

You are welcome to choose your academic level and the type of your paper. Our academic experts will gladly help you with essays, case studies, research papers and other assignments.

Admissions

Admission help & business writing

You can be positive that we will be here 24/7 to help you get accepted to the Master’s program at the TOP-universities or help you get a well-paid position.

Reviews

Editing your paper

Our academic writers and editors will help you submit a well-structured and organized paper just on time. We will ensure that your final paper is of the highest quality and absolutely free of mistakes.

Reviews

Revising your paper

Our academic writers and editors will help you with unlimited number of revisions in case you need any customization of your academic papers