-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be84b17
commit 6f49454
Showing
4 changed files
with
77 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
# This program is an example of flow sensitivity as the behavior of the program is dependent on the flow of execution, specifically the values assigned to the 'a' and 'b' fields of the 'arith_op' object. | ||
# This program is an example of context sensitivity as the behavior of the program is dependent on the context of function call execution, specifically the values assigned to the 'a' and 'b' fields of the 'ArithmeticOperation' class objects. | ||
# Function which has a combined return type [int,str] | ||
# The given code is context sensitive because it produces different results based on the context in which it is executed. | ||
|
||
|
||
def arithmetic_op(a, b): | ||
result = None | ||
if a == 0: | ||
result = b | ||
elif b == 0: | ||
result = a | ||
def my_function(my_bool): | ||
if my_bool: | ||
x = 5 | ||
else: | ||
result = a + b | ||
|
||
if result <= 0: | ||
result = 0 | ||
else: | ||
result = "Positive" | ||
return result | ||
x = "Hello World!" | ||
return x | ||
|
||
|
||
result = arithmetic_op(5, 10) | ||
result = arithmetic_op(1.0, 10.0) | ||
result = arithmetic_op(-5, -10) | ||
result2 = my_function(0) | ||
result1 = my_function("False") | ||
print() |