PYTHON

Is attach below:

CSCI333 Assignment 04

Don't use plagiarized sources. Get Your Custom Essay on
PYTHON
Just from \$13/Page

Control Structure II – Repetition

1. (30 points, each 5 points) Multiple choice or True/False questions:

1) (5 points) range (5) is:

a) 0, 1,

2

, 3, 4, 5

b) 1, 2, 3, 4, 5

c) 0, 1, 2, 3, 4

d) 1, 2, 3,4

2) (5 points) range (6, 0, -2) is

a) 6, 4, 2

b) 6, 4, 2, 0

c) 6, 4, 2, 0, -2

d) -6, -4, -2, 0, -2

3) (5 points) Executing a break statement in while or for loop exits the loop immediately

a) True

b) False

4) (5 points) Executing a continue statement in while or for loop skips the remainder of the loop’s suite, and go to the top of the loop and continue with the next iteration (if any)

a) True
b) False

5) (5 points) Executing an else statement in a for loop specifies a block of code to be executed when the loop is finished:

for i in range(m):

print(i)

else:

print(“Done”)

a) True
b) False

6) (5 points)

The following loop is executed times:

a) a

int x = a

while x <= 2a :

x = x + 1

b) a + 1

c) a – 1

d) a + 2

2. (30 points, each 5 points) Hand-trace the following code. What is the output or what error/problem do you observe?

1) (5 points)

 n=1 while n < 7: print (n) if n==3: break n += 1 Output:

2) (5 points)

 n=1 while n != 50: print(n) n=n + 10 print (“Completed”) Output:

3) (5 points)

 for n in range (0, 9, 3): if n == 3: continue print (n) Output:

4) (5 points)

Output:

 for x in range (2): for y in range (3): print (x, y) else: print (“Finally done!”)

5) (5 points)

 for x in range(3): for y in range(x+2): print(“*”, end =””) print() Output:

6) (5 points)

Output:

 for i in range(3) : for j in range(5) : if j % 2 == 1 : print(“*”, end=””) else : print(“−”, end=””) print()

3. (15 points) Write a program to compute and output the sum of all even numbers between 2 and 100 (including 2 and 100)

· (10 points) Write your program here, or copy/paste a screenshot of your Program:

· (3 points) Screenshot of a Program Run:

· (2 points) Save the program as “sumEvenNum.py”. Upload the .py file as part of your submission.

4. (15 points) Write a program to take a positive number n from user input, compute and output the sum of all odd digits of n. (For example, if n is 32677, the sum would be 3+7+7 = 17)

For example, a program run:

· (10 points) Write the program here, or copy/paste the screenshot of your program

· (3 points) Screenshot of a Program Run:

· (2 points) Save the program as “sumOddDigits.py”. Upload the .py file as part of your submission.

5. (15 Points) Write a program to get a first integer input from the user, use while to get the next input and determine if the current input integer is the same with the previous input. If adjacent values are the same, output a message stating they are duplicate inputs. Process data until the sentinel “-1” is entered.

For example: A program run:

· (10 points) Write the program here, or copy/paste the screenshot of your program

· (3 points) Screenshot of a Program Run:

· (2 points) Save the program as “checkAdj.py”. Upload the .py file as part of your submission.

 What to submit: a) One word file ( x) named ”CSCI333-Assign04-YourFirstLastName ”, including answers to all questions and the python source code in text or screenshots of all programs. b) All the Python source files (.py) of the programming questions c) Create a folder named as “CSCI333-Assign04-YourFirstLastName” and put the word file and Python source files into one folder Submission d) Zip (compress) the folder and submit the zipped file in myLeo Note: Partial credit will be given so do what you can and make sure you show your work for each question. No credit be given if no work is shown. For example, as long as you submit the screenshot of the programming result and the .py file, you will get the corresponding points. Submission example: CSCI333-Assign04-YanLi.zip CSCI333-Assign04-YanLi sumEvenNum.py sumOddDigits.py checkAdj.py

2

What Will You Get?

We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.

Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.

Experienced Writers

Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.

On-Time Delivery

Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.

Complete Confidentiality

Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.

Authentic Sources

We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.

Moneyback Guarantee

Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.

Order Tracking

You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

Trusted Partner of 9650+ Students for Writing

From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.

Preferred Writer

Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.

Grammar Check Report

Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.

One Page Summary

You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.

Plagiarism Report

You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.

Free Features \$66FREE

• Most Qualified Writer \$10FREE
• Plagiarism Scan Report \$10FREE
• Unlimited Revisions \$08FREE
• Paper Formatting \$05FREE
• Cover Page \$05FREE
• Referencing & Bibliography \$10FREE
• Dedicated User Area \$08FREE

Our Services

• On-time Delivery

We create perfect papers according to the guidelines.

Professional Editing

We seamlessly edit out errors from your papers.

Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!

Check Out Our Sample Work

Dedication. Quality. Commitment. Punctuality

Categories
All samples
Essay (any type)
Essay (any type)
The Value of a Nursing Degree
Nursing
2

It May Not Be Much, but It’s Honest Work!

Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.

Process as Fine as Brewed Coffee

We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.

See How We Helped 9000+ Students Achieve Success

We Analyze Your Problem and Offer Customized Writing

We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.

• Clear elicitation of your requirements.
• Customized writing as per your needs.

We Mirror Your Guidelines to Deliver Quality Services

We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.

• Proactive analysis of your writing.
• Active communication to understand requirements.