Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Trace the while-loop and indicate the total trip count for the loop: total = 128 diy - 2 while total > 2: total /=

image text in transcribed
image text in transcribed
1. Trace the while-loop and indicate the total trip count for the loop: total = 128 diy - 2 while total > 2: total /= div div2 print("total = 8d, div = 8d" (total, div)) Trip count - 3 2. Trace the for-loop, compute the trip count. total = 0 for target in [ 27, 9, 18, 3]: total += target/3 print("total = $d" % (total)) Trip count = 3. Determine the sequence for each: a. range( 72, 144, 12) [. b. range( -10,11,2) [. c. range( -15, -76, -15) [ 4. Trace the for-loop, compute the trip count. total = 0 for target in range( 3, 13, 3): total += target print("total = $" % (total)) Trip count = 5. Trace the for-loop and determine what the loop does. in str = "apple" for target in range( 0, len (in str), 1) : print (instr[target]) count + 1 print("%d" $ (count)) 6. Trace the for-loop strl - I an empty string for target in "Cnd": strl + (target + "a") print("%s" % (str1)) 7. Trace the for-loop: strl = "my dog has fleas".split(" ") '# a space delimiter for target in strl: print("s" % (target)) 8. Write a loop to display every other character in a string, as in "periwinkle" would print "prwnl" (indices 0, 2, 4, 6, 8)

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Discuss how frequently households trade securities.

Answered: 1 week ago

Question

2. List the advantages of listening well

Answered: 1 week ago