Lab Goal : This lab was designed to demonstrate the similarities and differences in a for loop and a while loop.Lab Description : Write a for loop that accomplishes the same goal as a while loop and write a while loop that accomplishes the same goal as a for loop. Finally, write a loop your way: write either a for loop or a while loop that produces the appropriate output.Sample Output :***** While Loop String Cleaner ****I am Sam I am with the letter a removed by a while loop is I m Sm I m***** For Loop String Cleaner ****I am Sam I am with the letter a removed by a for loop is I m Sm I m***** For Loop Common Divisor ****The for loop determined the common divisors of 528 and 60 are12 6 4 3 2***** While Loop Common Divisor ****The while loop determined the common divisors of 528 and 60 are12 6 4 3 2***** My Total Loop My Way ****The total of even numbers from 1 to 1000 using a for loop is 250500The total of even numbers from 1 to 1000 using a while loop is 250500*Only one of the two output statements are required. For extra credit, do both

Answers

Answer 1

Answer:

See Explanation

Explanation:

Required:

Use for and while loop for the same program

(1) String Cleaner

#For Loop

name = "I am Sam"

result = ""  

for i in range(0, len(name)):  

   if name[i]!= 'a':  

       result = result + name[i]

print(result)

#While Loop

name = "I am Sam"

result = ""  

i = 0

while i < len(name):

   if name[i]!= 'a':  

       result = result + name[i]

   i+=1

print(result)

(2): Common Divisor

#For Loop

num1 = 528

num2 = 60

div = num2

if num1 > num2:

   div = num1

for i in range(2,div):

   if num1%i == 0 and num2%i==0:

       print(i,end = " ")

print()

#While Loop

num1 = 528

num2 = 60

div = num2

if num1 > num2:

   div = num1

i = 2

while i <div:

   if num1%i == 0 and num2%i==0:

       print(i,end = " ")

   i+=1

The iterates statements show the difference in the usage of both loops.

For the for loop, the syntax is:

for [iterating-variable] in range(begin,end-1)

-------

---

--

For the while loop, the syntax is:

while(condition)

-------

---

--


Related Questions

What is used to prevent all vlans from going across a trunk?

Answers

If you want to play Valorant with me my name is
Ticklemyguitar and my riot id is 2735

Which is not a primary function of excel

Answers

i’m not sure what your choices are for this, but i believe it’s word processing.

Explanation:

Word Processor , it's really cra ppy btw

Question 12)
What element should the introduction of an effective essay have?

A.
a call to action
B.
a main idea statement
C.
a summary of the topic
D.
evidence to support the details
E.
details to support the topic

Answers

Answer:

The introduction of your essay should have the summary of your topic.

Explanation:

You obviously need to know what to write for your essay otherwise you would have no ideas, clues, evidence, or any elaboration for what your writing about. Hope this helps

Your tasks include identifying competitors, determining your company's market penetration and consulting market research sources. These tasks are examples of:
This task contains the radio buttons and checkboxes for options. The shortcut keys to perform this task are A to H and alt+1 to alt+9.
A

search engine optimization (SEO).
B

off-site Web analytics.
C

on-site Web analytics.
D

pay-per-click.

Answers

Answer:

B. off-site Web analytics.

Explanation:

Marketing can be defined as the process of developing promotional techniques and sales strategies by a firm, so as to enhance the availability of goods and services to meet the needs of the end users or consumers through advertising and market research. The pre-service strategies includes identifying the following target market, design, branding, market research, etc.

Market research can be defined as a strategic technique which typically involves the process of identifying, acquiring and analyzing informations about a business. It involves the use of product test, surveys, questionnaire, focus groups, interviews, etc.

Web analytics refers to a strategic process which typically involves the collection of data, as well as the study of user behavior in an attempt to enhance or boost market share and sales. It is divided into two main categories;

I. on-site Web analytics.

II. off-site Web analytics.

In this scenario, your tasks include identifying competitors, determining your company's market penetration and consulting market research sources. These tasks are examples of off-site Web analytics.

Identify reasons that web designers had for using tables for layout in the early years of the web. Check all of the boxes that apply.

Using tables ensured the validity of HTML code.

Using tables let web designers mimic print layout.

HTML table code was designed for layout purposes.

Tables could be nested within other tables.

Answers

Answer:

2 & 4 and the one to the right of that is 1 & 4

Explanation:

Edge2021

Greedy Algorithm Design
A couple wants to buy n major items. They will buy one item per month. They will buy all of their items at the CrazySuperStore. Due to the current economy, it is known that at some point in the future there will be a single price hike on all items at the same time, but due to the uncertainty of economic processes, it is not known when that price hike will occur. For each of the n items the couple wants to buy, both the current price, ai and the future price, bi (bi > ai), are known. (Note that the individual price hikes on items may vary. For example, one item may go from $100 to $105 while another might go from $300 to $400. They only assumption you may make about the prices is that the second price is strictly higher than the first and that you have access to all before/after prices.) Devise a greedy strategy so that the couple is guaranteed to minimize the amount of money they spend on the items. Assume that no matter what, the couple will buy all items. Clearly describe your strategy and intuitively (or formally) prove why it's optimal.

Answers

Answer:

The algorithm is as follows:

1. Start

2. Get the number of items (n)

3. Get the current price of the n items (a1, a2..... an)

4. Get the possible hiked price of the n items (b1, b2..... bn)

5. Calculate the difference between the current and hiked prices for each item i.e. [tex]d_i = b_i - a_i[/tex]

6. Sort the differences in descending order (i.e. from the greatest to the least)

7. Buy items in this order of difference

8. Stop

Explanation:

The algorithm is self-explanatory; however, what it does is that:

It takes a list of the current price of items (say list a)

E.g: [tex]a = [100, 150, 160][/tex]

Then take a list of the hiked price of the items (say list b)

E.g: [tex]b = [110, 180, 165][/tex]

Next, it calculates the difference (d) between corresponding prices [tex]d_i = b_i - a_i[/tex]

[tex]d = [(110 - 100),(180-150),(165-160)][/tex]

[tex]d = [10,30,5][/tex]

Sort the difference from greatest to lowest (as the difference is sorted, lists a and b are also sorted)

[tex]d = [30,10,5][/tex]

[tex]a = [150, 100, 160][/tex]

[tex]b = [180, 110, 165][/tex]

If there is no hike up to item k, the couple would have saved (i = 1 to d[k-1])

Assume k = 3

The couple would have saved for 2 item

[tex]Savings = d[1] + d[2][/tex]

[tex]Savings = 30 +10[/tex]

[tex]Savings = 40[/tex]

The saved amount will then be added to the kth item in list a i.e. a[k](in this case k = 3) in order to buy b[k]

Using the assumed value of k

[tex]a[k] = a[3][/tex]

[tex]a[3] = 160[/tex]

[tex]b[3] = 165[/tex]

Add the saved amount (40) to a[3]

[tex]New\ Amount = 40 + 160[/tex]

[tex]New\ Amount = 200[/tex]

This new amount can then be used to buy b[3] i.e. 165, then they save the change for subsequent items

Consider the following field and incomplete method of some class. The method calcTotal is intended to return the sum of all values in vals.

private int[] vals;

public int calcTotal()
{
int total = 0;

/* missing code */

return total;
}
Which of the code segments shown below can be used to replace /* missing code */ so that calcTotal will work as intended?

I.
for (int i : vals)
{
total += i;
}
II.
for (int pos = vals.length; pos > 0; pos--)
{
total += vals[pos];
}
III.
int pos = 0;
while (pos < vals.length)
{
total += vals[pos];
pos++;
}


I only
II only
I and III
II and III
III only

Answers

Answer:

I and III  

Explanation:

We need a solution that iterates through the each item in the vals array and sums them (cumulative sum). The result should be held in total.

I:

This one uses enhanced for loop (i refers to the each value in vals) and sums the values.

II:

This one uses for loop, but the loop is not constructed well. The control variable of the loop, pos, initially set the length of the vals and the loop iterates while pos is greater than 0. If vals have 10, 20, 30 as values, the length would be 3. In this case, vals[pos] when pos is 3, would give us an error because last index would be 2 in that scenario. Also, you can't access the first value because loop will stop when pos is 0.

III:

This one uses a while loop and iterates each value in the vals and sums them. Note that in this case, the values pos have will be 0, 1, 2 ..., length-1 - which are valid to access each item.

In QBasic, create a number guessing challenge. Your program should generate a random number from 1-
100 (inclusive). Let the user guess a number. The program should let the user guess until they get the
correct number. After each input, the program should tell the user whether they guessed the correct
number, or if they guessed too high or too low. While the user is entering guesses, the program should
keep a count of the number of guesses that it takes to get the correct number. After the user guesses
the correct number, the program should congratulate the user and tell them how many guesses it took
them to get the correct number. By the way, if the user chooses carefully, they should be able to guess
the number within 7 tries. But, your program should still let the user keep guessing until they guess the
correct number

Answers

Answer:

yes

Explanation:


Describe the major elements and issues with system prototyping​

Answers

Answer:

Pic attached...

Hope it helps!!!

What is it called when you remove some information from a file or remove a file from the disk ? A) save b) delete c) edit d) remove

Answers

Answer:

delete is the answer okkkkkkkkkkkkkkkk

we are writing a program that takes a word and checks how many letters​

Answers

Answer:

def word_count(word):

return len(word)

a = word_count('scream')

print(a

Explanation:

Using python3:

def word_count(word):

#defines a function named word_count which takes in a single argument which is the word to be counted

return len(word)

#The only thing the function does is to count the number letters in the word.

For instance :

return len(word)

Calling the function and attaching it to the variable named a

Counts the number of letters in scream and assigns the result to a

a = word_count('scream')

print(a)

a gives an output of 6 ; which is the number of letters in scream.

a student received a poor grade on her last two language art tests. what are the steps she should take for solving this problem
PLEASE HURRYYYY!

Answers

Answer:

Study and do practice tests

Which is a monthly cost associated with renting a house?
A utility bills
O B. property tax
O c.security deposit

Answers

the answer is a. utility bills
Utility bills ........

state and explain 5 importance of ICT in an organization​

Answers

Answer:

Explanation:

ICT simply refers to Information technology and it is the digital technologies used in various sectors to help economic agents make use of information.

The importance of ICT include:

1. Communication: ICT is vital for communicating in organizations as information are spread faster and employees have quicker access to information.

2. Marketing and Sales: ICT is vital for the marketing of products as products can be advertised on social medias etc.

3. Efficiency and effectiveness: There's efficiency and effectiveness on the part of the organization as the needs of the customers are attended to quickly.

4. Improvement in management decision: ICT is also vital in the enhancement of management decisions.

5. It is also vital is the storage of vital data's in the organization.

Saitama And Tatsumaki Both Go Shopping Together ,Both have Have 50 loafs of bread , And Saitama takes 43 , How much do Tatsumaki have left?

Answers

Answer:

7

Explanation:

Answer:

7- and a nut

Explanation:

A palindrome is a string that is the same when read left to right as when read right to left. Write a program that determines if an arbitrary string is a palindrome. Assume that the string can have blanks, punctuation, capital letters and lower case.

Answers

Answer:

In Python:

strng = input("String: ")

revstrng = strng[::-1]

if strng == revstrng:

   print("True")

else:

   print("False")

Explanation:

This prompts user for string input

strng = input("String: ")

This reverses the string input by the user

revstrng = strng[::-1]

This checks if strings and the reverse string are equal

if strng == revstrng:

Prints True, if yes

   print("True")

Prints False, if otherwise

else:

   print("False")

g Consider the turning point problem again, but this time you are given a sequence of at least three integers, which consists of a decreasing subsequence followed by an increasing subsequence. Using the divide and conquer technique, develop a recursive algorithm that finds the index of the turning point in the sequence (that is, the point where it transitions from a decreasing subsequence to an increasing subsequence). For example, in the sequence [43 30 16 10 7 8 13 22], the integer 7 is the turning point and its index is equal to 4 (assuming the starting index is 0). So, the algorithm should return 4

Answers

Answer:

Explanation:

The following code is written in Python, it creates a recursive function that takes in a list as a parameter, then compares the first two items in the list if the first is greater, it increases the index by one and calls the function again. This is done until the turning point is found, it then prints out the position of the turning point int the list.

def find_turning_point(list, x=0):

   if list[x] > list[x + 1]:

       x += 1

       return find_turning_point(list, x)

   else:

       return "The turning point position is: " + str(x)

The Binder Prime Company wants to recognize the employee who sold the most of its products during a specified period. Write a query to display the employee number, employee first name, employee last name, email address, and total units sold for the employee who sold the most Binder Prime brand products between November 1, 2017, and December 5, 2017. If there is a tie for most units sold, sort the output by employee last name

Answers

The answer will be one month

The plot of a video game is developed by which of the following occupations?
O video game artist
O graphic artist
O video game designer
O computer game programmer

HELP PLSSS!!!

Answers

Answer:

c video game designer

Explanation:

Answer:

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

Explanation:

How does an online discussion group differ from one that is held face-to-face?

There is no need for group roles when holding online meetings.
Online discussion groups do not allow members to develop critical-thinking skills.
Group members are more likely to bond together as a group online than they would when meeting face-to-face.
Facilitating an online conversation may require even more work, so that participants continue engaging with one another online.

Answers

Answer: they always will have a different thinkage from others

Explanation:Some people need actual in person learning for better grades it also keeps them from getting distracted easily, they have different brains in everyone in the world everyone thinks, acts and talks in different ways some people dont need in person school because they would rather be online wich are both ok so yes they do bond together online but better in person.

Online discussion group differ from one that is held face-to-face as Group members are more likely to bond together as a group online than they would when meeting face-to-face. Thus, option C is correct.

What is software organization?

A system that defines how specific activities, in this case, the software development process, are directed to achieve corporate goals is referred to as an organizational structure. These activities could include putting rules, roles, and responsibilities in place.

There are four basic modes of collaboration, as illustrated by the exhibit "The Four Ways to Collaborate": a closed and authoritarian network (an elite circle), an open and hierarchical connectivity (an innovation mall), an open and flat network (an innovation community), and a shuttered and flat network (a consortium).

Groupware is software that allows a group of people to work together on the same system or application, regardless of where they are. Email, newsgroups, and many more are examples of groupware applications.

Thus, option C is correct.

For more details regarding collaborative applications, visit:

brainly.com/question/8453253

#SPJ3

PLEASE HELP ME WITH THIS PYTHON CODE::::: THANKS!!!



Lists are an example of a data abstraction.


A data abstraction can often contain different types of elements. It also provides a separation between the abstract properties of a data type (integer, boolean, string) and the concrete details of its representation. Basically, it doesn’t matter that the type are different!


Create an empty list. Append the integer 3, a string of "hello" and a boolean of False into the list. Print out each index individually. Now, remove the number 3 and False from the list.


Finally, print out the list again.

Answers

Answer:

Explanation:

The following Python code does exactly as requested. Once the list is created and the elements are added to it, it uses a for loop to print out each element individually. Then once the loop is over it removes the 3 and False elements from the list and creates another for loop to print the remaining element(s) individually again.

my_list = []

my_list.append(3)

my_list.append("hello")

my_list.append(False)

for x in my_list:

   print(x)

my_list.remove(3)

my_list.remove(False)

for x in my_list:

   print(x)

How do you open the Font dialog?​

Answers

Explanation:

Click the Home tab.

In the Fonts group, click the dialog box launcher button.

The button is found in the lower-right corner of the Font group.

The Font dialog box contains all the commands for formatting text, including quite a few that didn’t find their way into the Font group on the Ribbon. As with all text formatting, the commands you choose in the Font dialog box affect any new text you type or any selected text in your document.

When you’ve finished setting up your font stuff, click the OK button. Or click Cancel if you’re just visiting.

Use the Ctrl+D keyboard shortcut to quickly summon the Font dialog box.

hope my answer helps

pls mark this as brainlist

be sure to follow me and I will follow you back

stay safe

good day

What will be the output of using the element in the given HTML code?



1011 2


A.
10112
B.
10112
C.
21011
D.
21011

Answers

Answer:

i think c.

Explanation:

Answer:

Answer is B: 1011 with the two under

Explanation:

I got it right on plato

2.5 lesson practice edhesive

Answers

Answer:

Huh,.......? what.....?

Answer:

1. They are contained in the math module.

2. 0, 1, ... 7

3. 0.0 <= r < 5

Explanation:

Write a program that asks for 'name' from the user and then asks for a number and stores the two in a dictionary (called 'the_dict') as key-value pair. The program then asks if the user wants to enter more data (More data (y/n)? ) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list. Note: Ignore the case where the name is already in the dictionary. Example: Name: pransh

Answers

Answer:

Explanation:

The following is written in Python and does as the question requested. It asks the user for the information and adds it to the dictionary (the_dict) then it asks the user if they want to add more info and keeps adding to the_dict until the user states no. Once that happens the program places the dictionary into a tuple and prints out the results.

the_dict = {}

test_tup = ()

while True:

   key = input("Please enter a name: ")

   value = input("Please enter a number: ")

   the_dict[key] = value

   answer = input("More data (y/n)?").lower()

   if answer != 'y':

       break

test_tup = list(test_tup)

test_tup.append(the_dict)

test_tup = tuple(test_tup)

print(test_tup)

Which example requires that the manager use persuasion to achieve his/her goal?
How to use equipment Customer service procedures
Technology policies
Finding volunteers to work at a charity event

Answers

Answer: Finding volunteers to work at a charity event

Explanation:

Persuasion simply means convincing someone to do a particular thing. From the options given, the option that will use persuasion is finding volunteers to work at a charity event. In such case, tis isn't part of the job roles of the workers and should be persuaded before they can go as they'll go when they realize that it's beneficial in one way or the other.

For other options, a direct strategy is utilized as the purpose is clear and immediately started.

Add the following method to the Point class: public double distance(Point other) Returns the distance between the current Point object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 (y2 - y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0.
public class Point {
int x;
int y;
// your code goes here
}

Answers

Answer:

public class Point

{

  public int x;

  public int y;

  Point(int x,int y)

  {

      this.x=x;

      this.y=y;

  }

  public static void main(String[] args)

  {

      Point p1=new Point(-2,3);

      Point p2=new Point(3,-4);

      System.out.println("distance:"+distance(p1,p2));

 }

  private static double distance(Point p1,Point p2)

  {

      return Math.sqrt(Math.pow(p2.x-p1.x, 2)+Math.pow(p2.y-p1.y, 2));

  }

}

Explanation:

The java program defines the Point class and the public method 'distance' to return the total distance between the two quadrants passed to it as arguments (they are both instances of the Point class).

In half-wave rectification process, Vi=

Select one:

a. none of above

b. Vm

c. T/2

d. Sin wt​

Answers

Answer:

the right answer is

(b.) Vm

What can be changed when a style is modified?

tables
spelling
text content
font
answer fast!

Answers

Answer:

Font

no hate If I'm wrong :)

can you help me with this question please ​

Answers

d. half period because it is the converting of bidirectional current flow to unidirectional currency flow.
Other Questions
A student wrote the equation 620 = 124n. Which situation is best represented by this equation?A. Jaclyn paid $620 to stay at the hotel.She paid $124 per night for two rooms each.How many nights, n, did Jaclyn stay at the hotel?B. Jaclyn paid $620 to stay at the hotel.She paid $124 per night.How many nights, n, did Jaclyn stay at the hotel?C. Jaclyn paid $620 to stay at the hotel.The hotel gave her a discount of $124 off the orginal price.What was n, the amount of money Jaclyn would have original paid to stay at the hotel?D. Jaclyn paid $620 for her and her sister to stay at the hotel.Jaclyn stayed in her own room for several nights and paid $124 for her sister to stay in another room for one night.What was n, the amount of money Jaclyn paid for her own room at the hotel for those days? lable each change as chemical or physical How do you say "I like or It pleases me"?me gustate gustale gustanos gusta Please help, its geometry can someone help me pweaaaaaas describe cinder cone volcanoes Sue has $100 saved to buy concert tickets that go on sale in 8 weeks. She plans to save $15 every 2 weeks. Will Sue have enough money saved to buy 4 concert tickets that cost $50 each? What led to immigration laws based on national origin? A. Increased immigration from eastern Europe B. More immigrants from Asian countries C. Fewer Catholic and Jewish immigrants D. Immigrants coming to the United States with large families What are the traits of nationalism? One bundle of shingles covers 32 square feet. How many bundles should you buy to cover a roof that is 540 ft2? PLEASE PLEASE PLEASEHELP ME!!!!! Go drink some water what are example of Interdependence what colors can the colorblind not see? Q6. A triangle has base 9 cm and perpendicular height 5.6 cm. Work outthe area of the triangle. *5.6 cm9 cm Match the vocabulary to their definitions.1. cave a feature of wave erosion that forms when waves erode a layer of softer rock that underlies a layer of harder rock 2. cavern a part of the shore that sticks out into the ocean; its made of harder rock that resists erosion by waves 3. headland the process by which waves repeatedly hit the beach and some of the beach sediment moves down the beach with the current 4. longshore drift a deposit of windblown sand that forms when wind meets an obstacle 5. sand dune a natural underground void large enough for a human to enter 6. sea arch a deposit that forms from the cave floor as slow dripping carbonic acid builds up in a cone-shape 7. stalagmite a connection or system of underground caves formed chemically through things like acid rain PLEASE HELP. The two lines graphed below are parallel. how many solutions are there to the system of equation Please help asap!!!!have a good dayPLZZZ HELPIdentify the historical circumstances behind the attached document. Your response should be AT LEAST one paragraph. 2. Atoms combine to form molecules. Which of the following is another example of organization among living things? *A. Tissues combine to form cells.B. Cells combine to form tissues.C. Organs combine to form cells.D. Organs combine to form tissues. what is 2 ways to show 1:2