Created
May 9, 2022 10:09
-
-
Save donno2048/214de59923ada49d24118bd19f3abeb9 to your computer and use it in GitHub Desktop.
Python plus plus
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
from pypp import Str, Int, Float, cout, cin, endl | |
if __name__ == "__main__": | |
str1, str2, int1, float1 = Str(), Str(), Int(), Float() | |
cout << "Hello, " << "world!" << endl | |
cin >> str1 >> str2 >> int1 >> float1 | |
cout << str1 << endl << str2 << endl << (int1 + Int(1)) << endl << float1 << endl |
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
class Str: | |
value = None | |
def __init__(self, value: type = None) -> None: | |
self.value = value | |
def __str__(self) -> str: | |
return self.value | |
def __add__(self, other) -> str: | |
return Str(self.value + other.value) | |
class Int: | |
type = int | |
def __init__(self, value: type = None) -> None: | |
self.value = value | |
def __str__(self) -> int: | |
return self.value | |
def __add__(self, other) -> int: | |
return Int(self.value + other.value) | |
def __sub__(self, other) -> int: | |
return Int(self.value - other.value) | |
def __mul__(self, other) -> int: | |
return Int(self.value * other.value) | |
def __truediv__(self, other) -> int: | |
return Int(self.value / other.value) | |
def __floordiv__(self, other) -> int: | |
return Int(self.value // other.value) | |
def __mod__(self, other) -> int: | |
return Int(self.value % other.value) | |
def __pow__(self, other) -> int: | |
return Int(self.value ** other.value) | |
class Float: | |
type = float | |
def __init__(self, value: type = None) -> None: | |
self.value = value | |
def __str__(self) -> float: | |
return self.value | |
def __add__(self, other) -> float: | |
return Float(self.value + other.value) | |
def __sub__(self, other) -> float: | |
return Float(self.value - other.value) | |
def __mul__(self, other) -> float: | |
return Float(self.value * other.value) | |
def __truediv__(self, other) -> float: | |
return Float(self.value / other.value) | |
def __floordiv__(self, other) -> float: | |
return Float(self.value // other.value) | |
def __mod__(self, other) -> float: | |
return Float(self.value % other.value) | |
def __pow__(self, other) -> float: | |
return Float(self.value ** other.value) | |
class __Print: | |
def __lshift__(self, other: Str): | |
print(other, end="") | |
return self | |
class __Input: | |
def __rshift__(self, other: Str): | |
other.value = other.type(input()) | |
return self | |
cout = __Print() | |
cin = __Input() | |
endl = "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment