38.3k views
3 votes
PLEASE HELP THANK YOU

1. In programming, what is a string?
-Built-in module containing pre-written code for numeric and non-numeric data types -Cable connecting numeric and non-numeric data to the computer hardware
-Function used to print numeric and non-numeric data exactly as they are written
-Non-numeric data, consisting of a sequence of letters, numbers, spaces, and symbols

2. A runtime error means there is a problem with the computer's hardware, making it impossible to execute a program.
-True
-False

3. Which of the following is an example of a logic error in programming?
-Not using quotation marks and parentheses to print a string literal
-Printing an inaccurate statement, like print ("Dogs have wings.")
-Trying to perform an impossible task, like 5 / 0 -Using camelcase when a variable name contains two or more words

4. Which of the following is the proper way to assign a string literal value to a variable in Python?
-variableName = value -variableName = "value" -variable Name = value -variable Name = "value"

5. Read the following code used to calculate the total cost of a meal with a 20% tip:

mealCost = input ("What is the meal total?")
tip = mealCost *mealcost 0.20 totalcost = meal + tip

There is an error in the code. Which additional function needs to be used with the input() function?
-float()
-int ()
-print ()
-str()

2 Answers

1 vote

Final answer:

A string is non-numeric data consisting of letters, numbers, spaces, and symbols. Runtime errors occur when unexpected conditions happen while a program is running. Logic errors produce incorrect or unexpected results in a program.

Step-by-step explanation:

1. In programming, what is a string?

A string is non-numeric data, consisting of a sequence of letters, numbers, spaces, and symbols.

2. A runtime error means there is a problem with the computer's hardware, making it impossible to execute a program.

False. A runtime error occurs when a program encounters an unexpected condition while running, such as dividing by zero or accessing an invalid memory location.

3. Which of the following is an example of a logic error in programming?

Printing an inaccurate statement, like print("Dogs have wings."), is an example of a logic error. Logic errors do not cause the program to crash, but they produce incorrect or unexpected results.

4. Which of the following is the proper way to assign a string literal value to a variable in Python?

variableName = "value" is the proper way to assign a string literal value to a variable in Python.

5. Read the following code used to calculate the total cost of a meal with a 20% tip:

mealCost = input ("What is the meal total?")
tip = float(mealCost) * 0.20
totalcost = float(mealCost) + tip

There is an error in the code. The float() function needs to be used with the input() function to convert the input from a string to a floating-point number for proper calculations.

User Serzas
by
4.7k points
1 vote

Answer:

1) A string is "non-numeric data". In other words, it is text.

2) False, a runtime error means that there is a problem, but it will be with the software, not the hardware.

3) An impossible task such as dividing five by zero is a logical error. Not using quotes on a string would be a syntax error, printing an inaccurate statement is not an error at all (as far as the program is concerned anyway), and using camelcase on a variable with multiple words is a common convention.

4) variableName = "value"

5) The code provided here is illegible, so I can't give a straight answer. It seems to be missing operators.

User SerjG
by
5.2k points