Question

In: Computer Science

Write Boolean expressions in Python Programming: A currently have a different value than B B less...

Write Boolean expressions in Python Programming: A currently have a different value than B B less than the sum of the current values of A and C C is no more than 15. 75 is between the values of integers A and B Number N is divisible by 2 or it is divisible by 3. X is positive and Y is positive

Solutions

Expert Solution

Answer

In Python, variables are created the moment we assign a value to it. It also doesn't need a semicolon at the end of the statement. Python has some unique operators like and, or, not, is, etc. Based on this information, let's write the statements one-by-one.

1) A currently have a different value than B

Here, we can use both operators '!=' and ' is not'.

So, the answers are  A != B  and A is not B

2) B less than the sum of the current values of A and C

For this, the operator '< ' is used

So, the answer is B < A+C

3) C is no more than 15

The value of C is either less than 15 or equal to 15. The operator '<=' is used for this.

So, the answer is C <= 15

4) 75 is between the values of integers A and B Number​​​​​​​

75 is between integers A and B. Let's assume B is greater than A here. Then, the above statement is equivalent to A is less than 75 and B is greater than 75.

So, the answer is A < 75 and B >75

5) N is divisible by 2 or it is divisible by 3​​​​​​​

For testing divisibility, we check whether the remainder is zero or not. '%' operator is used to find the remainder in python.

So, the answer is N %2 == 0 or N %3 == 0

  Note: we can also use 'is' operator instead of '=='.

6) X is positive and Y is positive

Means X is greater than zero and Y is also greater than zero

So, the answer is X > 0 and Y > 0


Related Solutions

Python Programming 4th Edition: Write Boolean expression: 1)A currently have a different value than B 2)...
Python Programming 4th Edition: Write Boolean expression: 1)A currently have a different value than B 2) B less than the sum of the current values of A and C 3)C is no more than 15. 4) 75 is between the values of integers A and B 5) Number N is divisible by 2 or it is divisible by 3. 6) X is positive and Y is positive
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values...
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values to the variables. Print the results. a<b≥c , √a−7 b2 ≠c , d∨e∧f , a<b∨¬d ∧means and, ∨means inclusive or, ¬ means not. b) Write a program that asks a user whether he or she wants to become a Java programmer and determines if the user typed “yes” (Print true if yes and false otherwise.) Don't use the if statement here
Determine the value, true or false, of each of the following Boolean expressions, assuming that the...
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10. Give your answer as one of the values true or false. a. (count == 0) && (limit < 20) b. count == 0 && limit < 20 c. (limit > 20) || (count < 5) d. !(count == 12) e. (count == 1) && (x < y) f....
Write a program in Python to practice evaluating some logical expressions and determine whether the expressions...
Write a program in Python to practice evaluating some logical expressions and determine whether the expressions are equivalent. Read in a 0 or 1 integer value for each of the following variables: A, B, C, and D. Use an if…else statement to change the 0 and 1 integer values into True and False Boolean values. Booleans in Python have to have this capitalization (True/False, not true/false or TRUE/FALSE) and shouldn’t contain double quotes (which makes them a String instead of...
3. Simplify the following expressions using the properties of boolean algebra : 3A)    S(A,B,C) = A'B'C...
3. Simplify the following expressions using the properties of boolean algebra : 3A)    S(A,B,C) = A'B'C + A'BC + AB'C + ABC 3B) F(A,B,C) = A'B'C' + A'B'C + AB'C' + AB'C + ABC' + ABC
Part 1(15%): Please write the Boolean expressions below in the file, part5_1.js, in the appropriate functions....
Part 1(15%): Please write the Boolean expressions below in the file, part5_1.js, in the appropriate functions. part5_1.js script will execute if you load the part5_1.html file into the browser. Write a Boolean expression that checks that number num, has n digits. Assume that num is an integer.( consider both the positive and negative case for num) Assuming the following are the ingredients for Jamie Oliver's fried rice: 1/2 dozen green onion 1 teaspoon chilli jam 2 cups rice 2 tablespoon...
PYTHON: Write a function named is_palindrome() that returns boolean True if a word or phrase is...
PYTHON: Write a function named is_palindrome() that returns boolean True if a word or phrase is a palindrome, and boolean False if it is not. The palindromes for this problem are contained in the list below. You must use this list in your solution. Use a for loop to retrieve each palindrome and test it. Your script should test each string in the list of palindromes below. Be aware there's a second list of palindromes embedded in the palindromes list....
I need to write an interpreter for arithmetic expressions in Python. This program receives an input...
I need to write an interpreter for arithmetic expressions in Python. This program receives an input string with an arithmetic expression and does: 1. prints a ">>>" as if it was a terminal 2. lets us allocate a variable to a a numeric value (as "a = 3") then it stores {'a':3} to a dictionary memory 3. whenever it receives an expression or input, transform it to postfix notation and print it (even when allocating variables) 4. it is able...
Programming Python Jupiter notebook Write a Python program that gets a numeric grade (on a scale...
Programming Python Jupiter notebook Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range, it asks him/her to enter a numeric input in the correct range, instead of returning an error. Example: Enter your score: 78 Letter...
Python Programming: Write a RegEx that validates social security numbers
Python Programming: Write a RegEx that validates social security numbers
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT