Is attach below:
CSCI333 Assignment 04
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
Answer:
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
Answer:
3) (5 points) Executing a break statement in while or for loop exits the loop immediately
a) True
b) False
Answer:
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
Answer:
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
Answer:
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
Answer:
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)
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)
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
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.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
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.
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.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
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.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
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.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
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!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
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.
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.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.