diff --git a/lecture20261117/if/if02.py b/lecture20261117/if/if02.py index 37d13de..4869e29 100644 --- a/lecture20261117/if/if02.py +++ b/lecture20261117/if/if02.py @@ -9,8 +9,8 @@ print("A better method to define the code ...") data1 = 22 -if data1 > 7: - print(f"{data1} is greater than 7") +if data1 >= 7: + print(f"{data1} is greater than or equal to 7") # Or this form @@ -20,8 +20,8 @@ print("And another method to define the code ...") data1 = 22 data2 = 7 -if data1 > data2: - print(f"{data1} is greater than {data2}") +if data1 < data2: + print(f"{data1} is less than {data2}") print("Program ended") diff --git a/lecture20261117/if/if04.py b/lecture20261117/if/if04.py index 8956a55..5eef027 100644 --- a/lecture20261117/if/if04.py +++ b/lecture20261117/if/if04.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -# Program: if02 +# Program: if04 # Lists of numbers. These could be integers or floats. intList = [7, 2, 16, 18, 12, 21] diff --git a/lecture20261117/if/if05.py b/lecture20261117/if/if05.py index fc31f8a..325d820 100644 --- a/lecture20261117/if/if05.py +++ b/lecture20261117/if/if05.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -# Program: if03 +# Program: if05 # Lists of numbers. These could be integers or floats. intList = [7, 2, 16, 18, 12, 21] diff --git a/lecture20261117/if/if06.py b/lecture20261117/if/if06.py index bf9b1f5..c4ea525 100644 --- a/lecture20261117/if/if06.py +++ b/lecture20261117/if/if06.py @@ -4,4 +4,6 @@ principal = float(input("Enter a value for the principal: ")) -print(f"You entered the value {principal}") \ No newline at end of file +print(f"You entered the value {principal}") + +# Create an if statement to limit the loan principal to > $1000 and < $120,000. diff --git a/lecture20261117/if/if06_Solution.py b/lecture20261117/if/if06_Solution.py new file mode 100644 index 0000000..7e2a6b7 --- /dev/null +++ b/lecture20261117/if/if06_Solution.py @@ -0,0 +1,19 @@ + +# consider the following line from the autoloan program: + +principal = float(input("Enter a value for the principal: ")) + + +print(f"You entered the value {principal}") + +# Create an if statement to limit the loan principal to > $1000 and < $120,000. + + +if principal < 1000: + print(f"The value of the principal must be $1000.00 or greater") + exit(-1) + +if principal > 120000: + print(f"The value of the principal must be $120000.00 or less") + exit(-1) + diff --git a/lecture20261117/if/if06_Solution2.py b/lecture20261117/if/if06_Solution2.py new file mode 100644 index 0000000..d4f4b20 --- /dev/null +++ b/lecture20261117/if/if06_Solution2.py @@ -0,0 +1,16 @@ + +# consider the following line from the autoloan program: + +principal = float(input("Enter a value for the principal: ")) + + +print(f"You entered the value {principal}") + +# Create an if statement to limit the loan principal to > $1000 and < $120,000. + + +if principal < 1000 or principal > 120000: + print(f"The value of the principal must between $1000.00 and $120000.00") + exit(-1) + +