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
true of false one reason to move to a paperless society is that printers are becoming prohibitively expensive
Yakvenalex [24]
True because printers, which require paper, are becoming more expensive. A paperless society has the advantage of being cheaper in this aspect.
5 0
3 years ago
Sonora wants to extend the cells to be added in her formula. What is the quickest way to add more cells?
djyliett [7]

Answer:

D

Explanation: took the test on edge

7 0
3 years ago
Read 2 more answers
assume that name is a variable of type stirng that has been assigned a value write an expression whose value is the last charact
Snezhnost [94]

Answer:

The most straight forward way to do it: in general string are zero index based array of characters, so you need to get the length of the string, subtract one and that will be the last character, some expressions in concrete languages would be:

In Python:

name = "blair"

name[len(name) - 1]

In JavaScript:

name = "blair"

name[name.length - 1]

In C++:

#include <string>

string name = "blair";

name[name.length() - 1];

7 0
3 years ago
What is the informal language that programmers use to create models of programs that have no syntax rules and are not meant to b
Yuri [45]
Pcode (Pseudo-code).

-----------------------------
5 0
3 years ago
​You work for a company that is growing. Originally, all the users in all departments had access to all the data in the database
jeyben [28]

Answer:

B. Assign roles and privileges to users so that only job-relevant data is accessible to the user.

Explanation:

Certain departments will require certain information for certain processes. It is not recommendable for every user to access every information of the company as it may reveal vital information.

Hence, every role and department should be given certain privileges to information according to the tasks and needs of the role.

5 0
3 years ago
Other questions:
  • In a paragraph of no less than 125 words, explain what netiquette is and how it improves efficiency and productivity in the work
    14·1 answer
  • Describe three general methods for passing parameters to the operating system.
    6·1 answer
  • OSI is a seven-layered framework used to help define and organize the responsibilities of protocols used for network communicati
    6·1 answer
  • Assume that input file references a Scanner object that was used to open a file. Which of the following while loops shows the co
    6·1 answer
  • Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
    8·1 answer
  • A string with delimiters can be parsed into separate fields using the _____ class.
    8·1 answer
  • Demonstrate the register addressing mode for the following instructions. Also what addressing mode belongs to these instructions
    11·1 answer
  • What is computer code?<br> A. Java Script<br> B. XML<br> C. HTML<br> D. Any programming language
    6·1 answer
  • What is a focus of Accenture's point of view on blockchain in the marketplace?
    12·1 answer
  • How do I do this??? (Im in 9th)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!