199k views
2 votes
You don’t have to limit the number of tests you create to 10. If you want to try more comparisons, write more tests and add them to conditional tests.py. Have at least one True and one False result for each of the following: • Tests for equality and inequality with strings • Tests using the lower() function • Numerical tests involving equality and inequality, greater than and less than, greater than or equal to, and less than or equal to • Tests using the and keyword and the or keyword • Test whether an item is in a list • Test whether an item is not in a list

1 Answer

4 votes

Answer:

car = 'subaru'

print("Is car == 'subaru'? I predict True.")

print(car == 'subaru')

print("Is car == 'audi'? I predict False.")

print(car == 'audi')

print("\\Is car != 'subaru'? I predict False.")

print(car != 'subaru')

print("Is car != 'audi'? I predict True.")

print(car != 'audi')

print("\\Is car == 'SUBARU'.lower()? I predict True.")

print(car == 'SUBARU'.lower())

print("Is car != 'SUBaRU'.lower()? I predict False.")

print(car != 'SUBaRU'.lower())

num = 10

print("\\Is num == 10? I predict True.")

print(num == 10)

print("Is num != 10? I predict False.")

print(num != 10)

print("Is num > 1? I predict True.")

print(num > 1)

print("Is num < 10? I predict False.")

print(num < 10)

print("Is num <= 10? I predict True.")

print(num <= 10)

print("Is num >= 11? I predict False.")

print(num >= 11)

# grouping conditions using and/or

# and evaluates to true if both conditions are true else false

# or evaluates to false when both conditions are false else true

print("\\Is num == 10 and car == 'subaru'? I predict True.")

print(num == 10 and car == 'subaru')

print("Is num != 10 and car == 'subaru'? I predict False.")

print(num != 10 and car == 'subaru')

print("Is num == 10 or car != 'subaru'? I predict True.")

print(num == 10 or car != 'subaru')

print("Is num != 10 or car != 'subaru'? I predict False.")

print(num != 10 or car != 'subaru')

# checking if value exists in an array

arr = [1,2,3,4,5]

print("\\Is 1 in arr? I predict True.")

print(1 in arr)

print("Is 6 in arr? I predict True.")

print(6 in arr)

Step-by-step explanation:

Conditional statements essentially evaluates to true or false based on a condition. It is frequently used in coding to decide the flow of the code.

The program applied conditional statement to evaluate the true and false of the statements based on the condition.

User OldFrank
by
5.0k points