Question

In: Computer Science

THIS IS A PYTHON ASSIGNMENT 1. The following are invalid variable names: 3g, 87 and 2h....

THIS IS A PYTHON ASSIGNMENT

1. The following are invalid variable names: 3g, 87 and 2h.

2. The operator != is an example of a relational operator.

3. A variable name identifies the kind of information stored in the object.

4. Python treats the variable names, a1 and A1, as the same variable.

5. The if/else selection structure is a single-selection structure.

6 A fatal logic error causes a program to execute and produce incorrect results.

7) A repetition structure performs the statements in its body while some condition remains

true.

8) Function float converts its argument to a floating-point value.

9) Function call range( 1, 10 ) returns the sequence 1 to 10, inclusive.

10) Sentinel-controlled repetition uses a counter variable to control the number of times a set

of instructions executes.

11) The symbol = tests for equality.

.PYTHON

Solutions

Expert Solution

1. The following are invalid variable names: 3g, 87 and 2h - True

In python,variable names cannot start with a digit.

2. The operator != is an example of a relational operator. -  False

The operator != is a comparison operator

3. A variable name identifies the kind of information stored in the object -  False

In python, variable names does not contain the data type. variable can be assigned with any kind of information.

4. Python treats the variable names, a1 and A1, as the same variable. - False

Variable in python are case sensitive

5. The if/else selection structure is a single-selection structure. - True

Python allows one set of statements to be executed if a condition is true and another set of actions to be executed if a condition is false.

6. A fatal logic error causes a program to execute and produce incorrect results. - True

Logical errors are the most difficult to fix. They occur when the program runs without crashing, but produces an incorrect result. The error is caused by a mistake in the program’s logic.

7. A repetition structure performs the statements in its body while some condition remains true - True

Repetition structures, or loops, are used when a program needs to repeatedly process one or more instructions until some condition is met, at which time the loop ends.

8. Function float converts its argument to a floating-point value. - True

The float() method is used to return a floating point number from a number or a string.

9. Function call range( 1, 10 ) returns the sequence 1 to 10, inclusive. - False

The function returns the sequence from 1 to 9 inclusive.

10. Sentinel-controlled repetition uses a counter variable to control the number of times a set of instructions executes. - False

Sentinel-controlled repetition is sometimes called indefinite repetition because it is not known in advance how many times the loop will be executed.

11. The symbol = tests for equality. - False

Operator = is for assignment , Operator == tests for equality.


Related Solutions

1. Adhere to the naming conventions discussed in class for variable names, program names, and function...
1. Adhere to the naming conventions discussed in class for variable names, program names, and function names 2. Use meaningful names for variables 3. Follow the coding standards and homework submission rules as covered in class. 4. If there are more than one word in the variable use all lowercase and separate them with underscores, e.g., first_name, shipping_cost. 5. Include appropriate comments in the code, but not too many. 6. Output should be displayed exactly as shown for each problem...
Indicate which of the following are valid C++ variable names and which are not. If not,...
Indicate which of the following are valid C++ variable names and which are not. If not, state the reason the name is invalid. Variable Name Valid – Yes/No If Invalid – Reason income 2time int Tom's two fold c3po income#1 item
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 =...
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 = 'abcdefghijklmnopqrstuvwxyz' Now write expressions—on separate lines of code—using sting s1 and the indexing operator that evaluate to 'm', 'p', 'z', 'e', 'a'. 2. Write Python statements that correspond to the following: a. assign to variable flowers a list containing strings 'rose', 'bougainvillea', 'yucca', 'marigold', 'daylily', and 'lily of the valley'. b. Write Boolean expressions that evaluate to True if the string ‘carrot’ is in...
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names...
1.Suppose a dictionary Groceries maps items to quantities.     Write a python to print the names of the grocery items whose quantity exceeds 400.     For example, if groceries = {‘cake mixes’: 430, ‘cheese’:312, ‘Orange’:525, ‘candy bars’: 217}         The output will be                                 Cake mixes                                 Orange 2. which Python string method would be the best choice to print the number of time “the” occurs in a sentence entered by the user? Provide a one word answer. Just...
Python: High school assignment, please keep simple In python: Use the following initializer list to create...
Python: High school assignment, please keep simple In python: Use the following initializer list to create an array: twainQuotes = ["I have never let my schooling interfere with my education.", "Get your facts first, and then you can distort them as much as you please.", "If you tell the truth, you don't have to remember anything.", "The secret of getting ahead is getting started.", "Age is an issue of mind over matter. If you don't mind, it doesn't matter. "]...
1. INTRODUCTION The goal of this programming assignment is for students to write a Python program...
1. INTRODUCTION The goal of this programming assignment is for students to write a Python program that uses repetition (i.e. “loops”) and decision structures to solve a problem. 2. PROBLEM DEFINITION  Write a Python program that performs simple math operations. It will present the user with a menu and prompt the user for an option to be selected, such as: (1) addition (2) subtraction (3) multiplication (4) division (5) quit Please select an option (1 – 5) from the...
Determine whether the following categorical syllogisms are valid or invalid. Categorical syllogism 1 No M are...
Determine whether the following categorical syllogisms are valid or invalid. Categorical syllogism 1 No M are P. No M are S No S are P. Categorical syllogism 2 Some M are not P. Some M are S. Some S are not P. Categorical syllogism 3 Some M are not P. Some M are not S. Some S are P. Categorical syllogism 4 All M are P. All S are M. All S are P. Categorical syllogism 6 No M are...
1. Show that the following argument is invalid by writing out its logical form and substituting...
1. Show that the following argument is invalid by writing out its logical form and substituting new terms that demonstrate its invalidity. Some policemen are handsome Some nurses are not handsome Some policemen are nurses 2.Show that the following argument is invalid by writing out its logical form and substituting terms that demonstrate its invalidity. All planets are comets All comets are stars All stars are planets 3. Explain why the following argument is invalid directly (in other words, do...
by using Fortran.90 solve the Question below? Q1)Correct the names of the following variable according to...
by using Fortran.90 solve the Question below? Q1)Correct the names of the following variable according to the fortran.90 stander. 1)Max'power, 2) 2*level, 3) low temp,   4) High(speed) Q2)Which of the following are invalid names in Fortran 90 and why? 1)A_HUGE_NUMBER 2)thedate 3)abignumber 4)Program 5)10times 6)Time.minutes 7)HELP!                                                                    1066(8        9)another-number 10)no way 11)f[t] 12)X
(Python) Write a program which accomplishes the following tasks: set a variable to the result of...
(Python) Write a program which accomplishes the following tasks: set a variable to the result of mathematical expression including +, -, * and / and of both Integer and Float values (or variables) set a variable to the result of a combination of string values (or variables) set a variable to the result of a combination of string, Integer and Float values (you may need to use the type casting functions) Using the following variables: a = 1.3 b =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT