Question

In: Computer Science

Fix this broken code? # Get our input from the command line import sys string =...

Fix this broken code?

# Get our input from the command line
import sys
string = sys.argv[1]

# Your code goes here
if string 'Bingo'
print('Missed')
else:
print('Hit!')

Solutions

Expert Solution

Here is the fix.

================================================================

# Get our input from the command line
import sys

string = sys.argv[1]

# Your code goes here
if string == 'Bingo':
    print('Missed')
else:
    print('Hit!')

=============================================================

You need to pass the argument to the program, if you are using Pycharm IDE, here is the screenshot as how you can configure passing the word as an argument


Related Solutions

Write a driver to get a String input from keyboard and if the input string has...
Write a driver to get a String input from keyboard and if the input string has less than 10 characters, throw a StringTooShortException. public class StringTooShortException extends Exception {     //-----------------------------------------------------------------     // Sets up the exception object with a particular message.     //-----------------------------------------------------------------     public StringTooShortException()     {         super("String does not have enough characters");     } }
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from...
Python 3 Fix the code and rovide the correct indentation Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) # entries barcode = tk.Entry(window) product = tk.Entry(window) money =...
C++ Text message decoder Use getline() to get a line of user input into a string:...
C++ Text message decoder Use getline() to get a line of user input into a string: Enter text: IDK if I'll go. It's my BFF's birthday. Search the string using find() for common abbreviations and replace() them with their long form. In addition, use a for loop to iterate through each character of the string and replace any occurences of '.' with '!': Enter text: IDK if I'll go. It's my BFF's birthday. I don't know if I'll go! It's...
q7.1 Fix the errors in the code (in C) //This program should read a string from...
q7.1 Fix the errors in the code (in C) //This program should read a string from the user and print it using a character pointer //The program is setup to use pointer offset notation to get each character of the string #include <stdio.h> #include <string.h> int main(void){ char s[1]; scanf(" %c", s); char *cPtr = s[1]; int i=0; while(1){ printf("%c", cPtr+i); i++; } printf("\n"); }
fix this code in python and show me the output. do not change the code import...
fix this code in python and show me the output. do not change the code import random #variables and constants MAX_ROLLS = 5 MAX_DICE_VAL = 6 #declare a list of roll types ROLLS_TYPES = [ "Junk" , "Pair" , "3 of a kind" , "5 of a kind" ] #set this to the value MAX_ROLLS pdice = [0,0,0,0,0] cdice = [0,0,0,0,0] #set this to the value MAX_DICE_VAL pdice = [0,0,0,0,0,0] cdice = [0,0,0,0,0,0] #INPUT - get the dice rolls i...
Use C++ to write a program that reads in a binary string from the command line...
Use C++ to write a program that reads in a binary string from the command line and applies the following (00, 1101) tag-system: if the first bit is 0, deletes the first three bits and append 00; if the first bit is 1, delete the first three bits and append 1101. Repeat as long as the string has at least 3 bits. Try to determine whether the following inputs will halt or go into an infinite loop: 10010, 100100100100100100. Use...
1. Read a line of input from the user (as a string) and find out if...
1. Read a line of input from the user (as a string) and find out if there are any vowels in the string. Use a break or continue keyword (whichever is appropriate) to notify that a vowel has been found. Prompt for another string and search again until the user enters 'exit' into the program. 2. Ask the user how many random numbers they would like to see. Ask the user to provide the lowest number they would like to...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner;...
Can you fix the errors in this code? package demo; /** * * */ import java.util.Scanner; public class Booolean0p {        public class BooleanOp {            public static void main(String[] args) {                int a = 0, b = 0 , c = 0;                Scanner kbd = new Scanner(System.in);                System.out.print("Input the first number: ");                a = kbd.nextInt();                System.out.print("Input...
Please fix all of the errors in this Python Code. import math """ A collection of...
Please fix all of the errors in this Python Code. import math """ A collection of methods for dealing with triangles specified by the length of three sides (a, b, c) If the sides cannot form a triangle,then return None for the value """ ## @TODO - add the errlog method and use wolf fencing to identify the errors in this code def validate_triangle(sides): """ This method should return True if and only if the sides form a valid triangle...
In Coral Code Please!!!! The assignment is to get an integer from input, and output that...
In Coral Code Please!!!! The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is configured to have students programming directly in the zyBook. Instructors may instead require students to upload a file). Below is a program that's been nearly completed for you. Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), or no output. Remember to always pre-enter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT