1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
7nadin3 [17]
3 years ago
12

What is wrong with this code and correct it.

Computers and Technology
1 answer:
balandron [24]3 years ago
8 0

Answer:

What's wrong?

The line_str variable needs to be re-initialized at the end of each printing

The correction

Include the following line immediately after the print statement

       line_str = ""

Explanation:

Required

Correct the code

The conditions are correct. However, the string variable line_str needs to be set to an empty string at the end of every of the iteration loop.

This will allow the code to generate a new string.

So, the complete function is:

<em>def swapping_stars(): </em>

<em>    line_str = "" </em>

<em>    for line in range(0, 6): </em>

<em>        for char in range(0,6): </em>

<em>            if line % 2 == char%2: </em>

<em>                line_str += "*" </em>

<em>            else: </em>

<em>                line_str += "-" </em>

<em>        print(line_str) </em>

<em>        line_str = ""</em>

You might be interested in
4. The Internet may best be compared to a/an A. series of colored lights. B. loud truck motor. C. enormous skyscraper. D. large
Triss [41]
D. Large network of roads.

A resembles a modem/router and C a webserver.
6 0
3 years ago
Name the different types of constructors that a designer can provide in a class. Provide an example with a class showing many co
Marrrta [24]
By default, if you do not implement a constructor, the compiler will use an empty constructor (no parameters and no code). The following code will create an instance of the MyObject class using the default constructor. The object will have the default vauesfor all the attributes since no parameters were given.

MyObject obj = new MyObject();

Another type of constructor is one with no parameters (no-arg constructor). It is similar to the default, except you actually create this constructor. The contents of the the constructor may include anything. To call a no-arg constructor, use the same line of code as above. The constructor can look like the one below:

public MyObject() {
System.out.println("This is a no-arg constructor");
}

Lastly there is the parameterized constructor. This type of constructor takes in parameters as inputs to assign to values in the newly created object. You call a parameterized constructor as follows:

MyObject obj = new MyObject("Bob", 20);

The constructor will look like this:

public MyObject(String name, int age) {
this.name = name;
this.age = age;
}

In the constructor, the keyword "this" refers to the object, so this.name is a private global variable that is being set equal to the inputted value for name, in this case "Bob".

Hope this helps!
8 0
3 years ago
Is there any way to delete old questions on this? if there is no way, take this as a free question​
Lostsunrise [7]

Answer:

moderators have to delete it for u

Explanation:

8 0
3 years ago
Read 2 more answers
how do i create an advanced search using the search criteria in the range K2:S3 and the inventory data where the results will be
valentina_108 [34]

Create an advanced search using the search criteria in the range K2:S3 and the inventory data where the results will be displayed in the search results (starting in cell K10).

Explanation:

  • In cell B2, enter the value from A7.
  • Insert a function in D2 that will return the arrival date of any vehicle based on  which VIN is entered in B2 (Hint: Start with an INDEX function. Before you use a  nested MATCH function, specify which column number you will be returning.)
  • Insert a function in F2 that will return the Special Notes of any vehicle based on  which VIN is entered in B2 (Use the same hint from the previous step.)
  • Enter the following values for the advanced search criteria in the range K3S3:
  1. Year = 2018
  2. Type = Sedan
  3. GPS = Yes
  • Create an advanced filter using the search criteria in the range K2:S3 and the  inventory data where the results will be displayed in the search results (starting in  K10).
  • Verify results populate as expected.
6 0
3 years ago
What is a computer meaning
goldenfox [79]

Answer:

computer means an electronic machine which process raw data and gives meaningful information to the user

7 0
3 years ago
Other questions:
  • A job application is a form used to make a job request.<br> True<br> False
    8·2 answers
  • Describe network in terms of the class computer lab
    9·1 answer
  • Which of the following STEM discoverers developed a new type of computer hardware?
    11·1 answer
  • Once you resize a photograph, it cannot be returned to its original size. TRUE or FALSE
    8·1 answer
  • What will be the output of the following code? &lt;?php $foo = 'Bob'; $bar = $foo; $bar = "My name is $bar"; print $bar; print $
    8·2 answers
  • Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
    9·2 answers
  • Consider the following code snippet:
    13·1 answer
  • 1. I write about my travel experiences on my own personal ____?
    12·1 answer
  • A serial schedule:
    8·1 answer
  • How does 5G technology enhance the Internet of Things (IoT)?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!