fix(r-1.2.py): fixed code to match findings in scratch.py
This commit is contained in:
@@ -3,6 +3,7 @@ def is_multiple(n, m):
|
|||||||
print(True)
|
print(True)
|
||||||
else:
|
else:
|
||||||
print(False)
|
print(False)
|
||||||
|
|
||||||
print('Is "n" a multiple of "m"?')
|
print('Is "n" a multiple of "m"?')
|
||||||
is_multiple(float(input('Give a value for n: ')), float(input('Give a value for m: ')))
|
is_multiple(float(input('Give a value for n: ')), float(input('Give a value for m: ')))
|
||||||
|
|
||||||
+7
-4
@@ -2,14 +2,17 @@
|
|||||||
Full disclosure, prior to attempting this, I actually looked at the link
|
Full disclosure, prior to attempting this, I actually looked at the link
|
||||||
at the top of page 51, and even visited it. I also relied heavily on w3schools
|
at the top of page 51, and even visited it. I also relied heavily on w3schools
|
||||||
compared to the textbook. While initially learning Python, I found the language
|
compared to the textbook. While initially learning Python, I found the language
|
||||||
of the book difficult, but as I grasped concepts, it came easier.
|
of the book difficult, but as I grasped concepts, it came easier. I will also
|
||||||
|
be creating scratch files when needed to test ideas. They will not be submitted
|
||||||
|
with my lab submissions but will be available at my Gitea link posted with
|
||||||
|
my submitted files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def is_even(k):
|
def is_even(k):
|
||||||
if k & 2 != 10: # I first thought to compare the var to an even number
|
if k & 1 == 0:
|
||||||
print(False)
|
|
||||||
else:
|
|
||||||
print(True)
|
print(True)
|
||||||
|
else:
|
||||||
|
print(False)
|
||||||
|
|
||||||
print('Is "k" an even number?')
|
print('Is "k" an even number?')
|
||||||
is_even(int(input('Give a value for k: ')))
|
is_even(int(input('Give a value for k: ')))
|
||||||
@@ -13,7 +13,7 @@ which would be either 2 or 0.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
k = (int(input('Give a value for k... ')))
|
k = (int(input('Give a value for k... ')))
|
||||||
l = k & 2
|
l = k & 1
|
||||||
print(l)
|
print(l)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user