Question

Users\trinv\Downloads\Test 3_Debugging Question(1).py - Notepad++ dit Search View Encoding Language Settings Tools Macro Run

C:\Users\trin Downloads\Test 3 Debugging Question(1).py - Notepad++ File Edit Search View Encoding Language Settings Tools Ma

need help debugging please

need to know why isn't running and how to fix it

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE :

a = -10 ## a not initialised
while(a < 0):
print(a)
a = a+2 ## statement should contain '+' because otherwise it will always be less than 0 for a negative number and not give any output for a positive number
## also this statement should be inside the while loop and not outside, else it would run infinite number of times

OUTPUT SNIPPET :

-10 -台 - -4 -2

CODE :

for k in [1,2,3,4,5,6,7,8,9,10]: ## colon was missing in the syntax of for loop
print("k: ", k)

OUTPUT SNIPPET :

k: k: k: k: k: k: 1 2 3 4 5 6 7 8 9 10

CODE :

for n in range(70,100,10): ## there was an increment of 0 because of which it was running infinitely you can add any positive number for the increment
print(n)

OUTPUT SNIPPET :

70 80 90

CODE :

m = 5
while(m == 5): ## assignment operator '=' was used which will always make the while condition true and hence infinite run
print(m)
m = m+1

OUTPUT SNIPPET :

un

CODE :

str = input("Enter some text: ")
u = 0
while(str != 'X' and str != 'x'): ## to come out of the while loop we need to get the input every time or this will either print nothing or run infinite times
print(str)
u = u+3
str = input("Enter some text: ")

OUTPUT SNIPPET :

Enter some text: z z Enter some text: Y Y Enter some text: x

CODE :

a = 0
while(a < 30):
print("a = ", a)
a = a+3 ## increment operator should be used because using '-' would decrease the value of a every time and it will always be less than 30, hence it will run infinite times

OUTPUT SNIPPET :

d = e ೫) J = | a - d d = 12 15 18 21 24 27 ಥ ಥ =

  • Mistakes in each code have been written as a comment
  • Correct code is written along with explanation
  • Output snippets added for each code

Please give an upvote if you liked my answer. Thank you :)

Add a comment
Know the answer?
Add Answer to:
need help debugging please need to know why isn't running and how to fix it Users\trinv\Downloads\Test...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please assist. I keep getting the error message in the middle screen when I run the...

    Please assist. I keep getting the error message in the middle screen when I run the program on the left. The image on the right is the section of images.py where it's indicating the issue with the .split is. How do I fix this? images.cy - /Users/carrietarpy Downloads/lab9-3/images.py 12.7.18) Python 2.7.18 Shell Python 2.7.15 (v2.7.18:542 102112, Apr 19 2820, 29:48:48) [GCC 4.7.1 Compatible Apple II w 6.3 Clong-FA3.0.57)] on der in Type "help", "copyright', 'credits' or "license()' for more inforyotion...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options...

    Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options Window Help #Declare a variab i e and initialize it def displayInstructions (1angCode): 3tr . ENGLISHPROMPT = "Please enter your weight in poundョ >> " str.SPANISH PROMPT Por favor entre en su peso en libras > if langCode1: - print ("ENGLISH prompt) print ("SPANISH prompt") print ("Stop") elif langCode2 else: code input ( Enter code for instructions") num code weight = input ("Enter weight...

  • For my computer class I have to create a program that deals with making and searching...

    For my computer class I have to create a program that deals with making and searching tweets. I am done with the program but keep getting the error below when I try the first option in the shell. Can someone please explain this error and show me how to fix it in my code below? Thanks! twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • Dle Edit Search View Encoding Language Settings Tools Macro Run Plugins Window 1 isport turtle 3 ...

    dle Edit Search View Encoding Language Settings Tools Macro Run Plugins Window 1 isport turtle 3 tina turtle.Turtle 4 SCreen-turtle.Screen ) 5 acreen.bgoolor ("white") 6 tina.shape ("turtle" 7tina.pencolor ("blue") SCALE -20 10 12 13 14 15 16 17 18 19 20 21 input: n # output: a drawing of n concentric circles centered at 0,0 # this function is written using iteration (using a loop) Edef concentric loop (n) : for size in range(n) : tina.penup tina goto (O, -SCALE...

  • //please help I can’t figure out how to print and can’t get the random numbers to...

    //please help I can’t figure out how to print and can’t get the random numbers to print. Please help, I have the prompt attached. Thanks import java.util.*; public class Test { /** Main method */ public static void main(String[] args) { double[][] matrix = getMatrix(); // Display the sum of each column for (int col = 0; col < matrix[0].length; col++) { System.out.println( "Sum " + col + " is " + sumColumn(matrix, col)); } } /** getMatrix initializes an...

  • 6-1 Test and debug the Invoice Application i need help with this please.. all help is...

    6-1 Test and debug the Invoice Application i need help with this please.. all help is appreciated Source code Java: import java.util.Scanner; import java.text.NumberFormat; public class InvoiceApp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (!choice.equalsIgnoreCase("n")) { // get the input from the user System.out.print("Enter customer type (r/c): "); String customerType = sc.next(); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // get the discount percent double discountPercent = 0.0; switch(customerType) {...

  • This is what I have now: I need to make modifications: G G E ? Q...

    This is what I have now: I need to make modifications: G G E ? Q Search Documentation $ Angie Workspace Name Hans Value 988 Hi 75 Ix76 double HOME PLOTS APPS EDITOR PUBLISH VIEW H E T G Find Files > Insert fx DE Run Section s Compare - Go To - New Open Save Corriment % % Breakpoints Run Run and Advance Run and - - Print Find Indent - Advance Time FILE NAVIGATE EDIT RRFAKPOINTS Users angiechoisfolder...

  • C#: I am working on this application and keep running into this error. Please help me fix it. Err...

    C#: I am working on this application and keep running into this error. Please help me fix it. Error: Design: Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SinghAjayProgram08 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } double totalInserted = 0; double totalWon = 0; private void spinButton_Click(object sender, EventArgs e) { Random rand = new Random(); int index = rand.Next(fruitsImageList.Images.Count); firstPictureBox.Image =...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT