This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Showing
62 changed files
with
1,200 additions
and
457 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
with entry { | ||
print <: "Hello world!" ; # print("Hello world!") | ||
print <: "Hello world!" ; | ||
a = [2,4,5,7,8]; | ||
b = [4,8,9,13,20]; | ||
c = len<:a + len<:b ; #len(a) + len(b) | ||
c = len<:a + len<:b ; | ||
print(c); | ||
|
||
} |
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 |
---|---|---|
|
@@ -4,6 +4,4 @@ with entry{ | |
|
||
del x; | ||
|
||
# Raises NameError because x is deleted | ||
#print("After Delete:", x); | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,3 @@ | |
print("Before Delete:", x) | ||
|
||
del x | ||
|
||
# Raises NameError because x is deleted | ||
# print("After Delete:", x) |
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,9 +1,3 @@ | ||
start_range = 1 | ||
end_range = 5 | ||
for i in range(start_range, end_range + 1): | ||
number = 1 | ||
while number <= 10: | ||
product = i * number | ||
print(f"{i} x {number} = {product}") | ||
number += 1 | ||
print("\n", end="") | ||
for i in "banana": | ||
for j in range(1, 3): | ||
print(i, j) |
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,8 +1,8 @@ | ||
with entry{ | ||
# Example usage of the lambda function | ||
calculate_rectangle_area = with length: float, width: float can length * width; | ||
rectangle_area = calculate_rectangle_area(5.0, 8.0); | ||
|
||
print(f"The area of the rectangle is: {rectangle_area}"); | ||
x = with a: int , b:int can a+b; | ||
print(x(5,4)); | ||
|
||
} | ||
|
||
|
||
} |
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,9 +1,2 @@ | ||
calculate_rectangle_area = lambda length, width: length * width | ||
|
||
# Example usage | ||
length = 5.0 | ||
width = 8.0 | ||
|
||
area = calculate_rectangle_area(length, width) | ||
|
||
print(f"The area of the rectangle is: {area}") | ||
x = lambda a, b: a + b | ||
print(x(5, 4)) |
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,64 +1,17 @@ | ||
|
||
with entry{ | ||
apples = 5; | ||
oranges = 8; | ||
|
||
# Check if there are more oranges than apples | ||
if oranges > apples{ | ||
print("There are more oranges than apples."); | ||
} | ||
else{ | ||
print("There are fewer oranges than apples."); | ||
} | ||
} | ||
|
||
with entry{ | ||
city1 = "New York"; | ||
city2 = "Los Angeles"; | ||
|
||
# Check if the cities are the same | ||
if city1 == city2{ | ||
print("Both cities are the same."); | ||
} | ||
else{ | ||
print("The cities are different."); | ||
} | ||
|
||
} | ||
|
||
with entry{ | ||
# Using is for identity comparison | ||
list1 = [1, 2, 3]; | ||
list2 = [1, 2, 3]; | ||
|
||
if list1 is list2{ | ||
print("list1 and list2 refer to the same object."); | ||
} | ||
else{ | ||
print("list1 and list2 are different objects."); | ||
} | ||
|
||
} | ||
with entry{ | ||
# Example with a list | ||
my_list = [1, 2, 3, 4, 5]; | ||
result = 3 in my_list; | ||
print(result); # Output: True | ||
|
||
} | ||
|
||
#logical OR,AND .jac | ||
with entry{ | ||
is_star_player = True; # Player is a star player | ||
has_high_score = False; # Player has a high score in the game | ||
is_team_captain = True; # Player is the team captain | ||
|
||
# Logical OR: Star Player or High Score | ||
access_allowed_or = is_star_player or has_high_score; | ||
print(f"Access allowed (OR): {access_allowed_or}"); # Output: True | ||
if 5 < 4{ | ||
print("True");} | ||
elif "a" != "b"{ | ||
print("'a' is 'a' ");} | ||
else{ | ||
print("No");} | ||
|
||
# Logical AND: Team Captain and Star Player | ||
access_allowed_and = is_team_captain and is_star_player; | ||
print(f"Access allowed (AND): {access_allowed_and}"); # Output: True | ||
a = [1, 2, 3]; | ||
b = [1, 2, 3]; | ||
print(a is b); | ||
print( 3 in a); | ||
|
||
print(True or False); | ||
print(False and False); | ||
} |
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,47 +1,13 @@ | ||
apples = 5 | ||
oranges = 8 | ||
|
||
if oranges > apples: | ||
print("There are more oranges than apples.") | ||
else: | ||
print("There are fewer oranges than apples.") | ||
|
||
|
||
city1 = "New York" | ||
city2 = "Los Angeles" | ||
|
||
# Check if the cities are the same | ||
if city1 == city2: | ||
print("Both cities are the same.") | ||
else: | ||
print("The cities are different.") | ||
|
||
|
||
list1 = [1, 2, 3] | ||
list2 = [1, 2, 3] | ||
|
||
if list1 is list2: | ||
print("list1 and list2 refer to the same object.") | ||
if 5 > 4: | ||
print("True") | ||
elif "a" == "a": | ||
print("'a' is 'a' ") | ||
else: | ||
print("list1 and list2 are different objects.") | ||
|
||
|
||
# in | ||
my_list = [1, 2, 3, 4, 5] | ||
result = 3 in my_list | ||
print(result) # Output: True | ||
|
||
is_star_player = True | ||
# Player is a star player | ||
has_high_score = False | ||
# Player has a high score in the game | ||
is_team_captain = True | ||
# Player is the team captain | ||
|
||
# Logical OR: Star Player or High Score | ||
access_allowed_or = is_star_player or has_high_score | ||
print(f"Access allowed (OR): {access_allowed_or}") # Output: True | ||
|
||
# Logical AND: Team Captain and Star Player | ||
access_allowed_and = is_team_captain and is_star_player | ||
print(f"Access allowed (AND): {access_allowed_and}") # Output: True | ||
print("False") | ||
a = [1, 2, 3] | ||
b = [1, 2, 3] | ||
print(a is b) | ||
print(3 in a) | ||
|
||
print(True or False) | ||
print(False and False) |
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,13 +1,10 @@ | ||
with entry{ | ||
data=" snoopy"; | ||
day=" sunday"; | ||
|
||
match data{ | ||
case "Ironman": | ||
print("You are Marvel fan"); | ||
case "Batman": | ||
print("You are DC fan"); | ||
match day{ | ||
case "monday": | ||
print("confirmed"); | ||
case _: | ||
print("You are not a Marvel or DC fan"); | ||
|
||
print("other"); | ||
} | ||
} |
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,9 +1,6 @@ | ||
data = "snoopy" | ||
match data: | ||
case "Ironman": | ||
print("You are Marvel fan") | ||
|
||
case "Batman": | ||
print("You are DC fan") | ||
day = " sunday" | ||
match day: | ||
case "monday": | ||
print("confirmed") | ||
case _: | ||
print("You are not a Marvel or DC fan") | ||
print("other") |
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,12 +1,9 @@ | ||
with entry{ | ||
num=89; | ||
match num{ | ||
# MatchSequence | ||
case 89: | ||
print("Correct"); | ||
case 8: | ||
print("Nope"); | ||
case 9: | ||
print("Nope"); | ||
} | ||
} |
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,9 +1,6 @@ | ||
num = 89 | ||
match num: | ||
# MatchSequence | ||
case 89: | ||
print("Correct") | ||
case 8: | ||
print("Nope") | ||
case 9: | ||
print("Nope") |
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,6 +1,5 @@ | ||
data = {"key1": 1, "key2": 2, "232": 3453} | ||
|
||
# MatchMapping | ||
match data: | ||
case {"key1": 1, "key2": 2, **rest}: | ||
print(f"Matched a mapping with key1 and key2. Rest: {rest}") |
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,8 +1,9 @@ | ||
with entry{ | ||
data=[1,2,3]; | ||
match data{ | ||
# MatchSequence | ||
case [1, 2, 3]: | ||
print("Matched a specific sequence [1, 2, 3]."); | ||
print("Matched"); | ||
case _: | ||
print("Not Found"); | ||
} | ||
} |
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,5 +1,6 @@ | ||
# MatchSequence | ||
data = [1, 2, 3] | ||
match data: | ||
case [1, 2, 3]: | ||
print("Matched a specific sequence [1, 2, 3].") | ||
print("Matched") | ||
case _: | ||
print("Not Found") |
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,8 +1,6 @@ | ||
a = 8 | ||
match a: | ||
case 7: | ||
print("Nope") | ||
case 8: | ||
print("Yep") | ||
print("Doable") | ||
case _: | ||
print("Not possible") | ||
print("Undoable") |
Oops, something went wrong.