Lecture 1: Conditionals Flashcards

1
Q

What are Conditionals? (with ex)

A

Conditionals allwo you as a programmer to let yout code makes decisions.
Ex: chose the right hand or the left hand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the main types of Assignment operators that we used to asl mathematical questions

A

1- > and < symbols
2- >= “greater than or equal to.”
3- <= “less than or equal to.”
4- == “equals, a single equal sign would assign a value in a string. Double-equal signs are used to compare variables.
5- != denotes “not equal to.
6- Conditional statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

elif is a python keyword that literally saying

A

if the previous conditions were not true, then try this condition. in other words, it allows the program to make less decisions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the job of or?

A

or is a type of Python Logical or Boolean Operators (عوامل) that allows your program to decide between one or more options

ex:
if x < y or x > y :
print(“x is not equal to y”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the job of and?

A

and is a type of Python Logical or Boolean Operators that ensure all of the Conditions (شروط) are true

ex:
if score >= 90 and score <= 100:
print(“Grade: A”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

One of the most common ways to improve our code is?

A

by asking fewer questions. This makes our program easier to read and far more maintainable in the future.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

in terms of programming we use the % symbol differently by?

A

The modulo % operator in programming allows us to see if two numbers divide evenly (بالتساوي) or divide and have a remainder (باقي)

For example, 4 % 2 would result in zero because it evenly divides. However, 3 % 2 does not divide evenly and would result in a number other than zero

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the job of match statements?

A

match statements can be used to conditionally run code that matches or connects certain values using “cases”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does case _ mean?

A

we use the _ symbol in the last case which will match with any input, resulting in similar behavior as an else statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we check for multiple values in the same case statement?

A

we use a single vertical bar |

ex:
match name:
case “Harry” | “Hermione” | “Ron”:
print(“Gryffindor”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the control flow?

A

It is the order in which code commands are executed

هو الترتيب الذي يتم فيه تنفيذ الأوامر البرمجية

How well did you know this?
1
Not at all
2
3
4
5
Perfectly