Conditional Statements in Programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/44

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

45 Terms

1
New cards

Simple Decision Structure

In a decision structure, some condition must be tested before some action can be performed.

2
New cards

Boolean Variables

The if clause asks a question, which is a boolean statement resulting in a boolean value: True or False.

3
New cards

Relational Operators

Boolean expressions can be built using relational operators such as <, >, <=, >=, ==, and !=.

4
New cards

Comparing Strings

The relational operators can also be used to compare strings using their ASCII codes.

5
New cards

If / Else Decision Structure

Sometimes, we want to do one thing if the condition is true and something else if the condition is not true.

6
New cards

Nested Conditional Statements

Multiple conditions are tested one after the other to make different decisions.

7
New cards

Logical Operators

Boolean expressions can be built using logical operators such as and, or, and not.

8
New cards

Assignment Operator

= is the assignment operator.

9
New cards

Comparison Relational Operator

== is the comparison relational operator.

10
New cards

ASCII Code

The ASCII code is used to compare two strings.

11
New cards

Example: Average.py

An example program demonstrating the use of averages.

12
New cards

Example: Overtime.py

An example program demonstrating the use of if/else decision structure.

13
New cards

Example: LoanQualifier.py

An example program demonstrating nested conditional statements for loan qualification.

14
New cards

Boolean Value

The result of a boolean question is a boolean value, either True or False.

15
New cards

Condition Testing

In a decision structure, some condition must be tested before some action can be performed.

16
New cards

True

A boolean value indicating a positive condition.

17
New cards

False

A boolean value indicating a negative condition.

18
New cards

Example: Salary Qualification

Does a person qualify for a loan? Salary >= 30000 and Years with job >= 2.

19
New cards

Result of Logical Operators

Result is true if both conditions are true for 'and', true if either condition is true for 'or', and true if the condition is false for 'not'.

20
New cards

Condition Structure

Using an 'and' operator creates a different nested conditional structure.

21
New cards

Loan Qualification Criteria

Salary < 30000 or Salary >= 30000 and Years with job >= 2

22
New cards

Minimum Salary Requirement

You must earn at least $30,000 to qualify

23
New cards

Minimum Job Duration Requirement

You must be on your current job for at least two years to qualify

24
New cards

Wi-Fi Diagnostic Tree

A flowchart used to troubleshoot Wi-Fi connection issues

25
New cards

Rebooting Process

Reboot the computer and try to connect; if that doesn't fix the problem, reboot the router and try again

26
New cards

Cable Check

Make sure the cables between the router and modem are plugged in firmly

27
New cards

Router Relocation

Move the router to a new location and try to connect

28
New cards

Order of Operations

Highest: *, , /, %, +, -; Lowest: <, <=, >, >=, ==, !=, not, and, or

29
New cards

if-elif-else Statement

Allows to sometimes do something and other times do another thing while many conditions are tested

30
New cards

elif

An abbreviation for 'else if', used to specify a new condition if the previous conditions are false.

31
New cards

random module

A module in Python that provides functions to generate random numbers.

32
New cards

random.random()

Generates a random floating-point number in the interval [0, 1).

33
New cards

random.randint(a, b)

Generates a random integer in the interval [a, b], inclusive.

34
New cards

Random number generation formula

To generate a random number in the interval [a, b), use: floatNumber = random.random() * (b - a) + a.

35
New cards

.lower() method

A string method that converts all letters in a string to lowercase.

36
New cards

.upper() method

A string method that converts all letters in a string to uppercase.

37
New cards

.capitalize() method

A string method that changes the first letter of a string to uppercase.

38
New cards

.title() method

A string method that changes the first letter of each word in a string to uppercase.

39
New cards

.isalnum() method

A string method that checks if all characters in a string are letters or digits.

40
New cards

.isalpha() method

A string method that checks if all characters in a string are letters.

41
New cards

.isdigit() method

A string method that checks if all characters in a string are digits.

42
New cards

.islower() method

A string method that checks if all letters in a string are lowercase, ignoring non-letter characters.

43
New cards

.isupper() method

A string method that checks if all letters in a string are uppercase, ignoring non-letter characters.

44
New cards

Example: RomanNumerals.py

A Python script example demonstrating the use of if, elif, and else clauses.

45
New cards

Example: Siblings.py

A Python script example that likely demonstrates string methods or random number generation.