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
def make_bigger(n: int) -> int: | |
''' | |
post: __return__ != 0 | |
''' | |
res1=20 | |
res2=20 | |
if n<50: | |
res1=1 | |
else: |
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
def make_bigger(n: int) -> int: | |
''' | |
pre: n != -5 | |
post: __return__ != 0 | |
''' | |
return 2 * n + 10 | |
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
def make_bigger(n: int) -> int: | |
''' | |
post: __return__ != 0 | |
''' | |
return 2 * n + 10 | |
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
import re | |
from typing import Optional | |
def parse_year(yearstring: str) -> Optional[int]: | |
''' | |
Something is wrong with this year parser! Can you guess what it is? | |
post: __return__ is None or 1000 <= __return__ <= 9999 | |
''' | |
return int(yearstring) if re.fullmatch('[1-9][0-9][0-9][0-9]', yearstring) else None |
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
def make_bigger(n: int) -> int: | |
''' | |
pre: n>=0 | |
post: __return__ != 0 | |
''' | |
return 2 * n + 10 | |
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
def make_bigger(n: int) -> int: | |
''' | |
post: __return__ > 0 | |
''' | |
if n > -10: | |
return n + 10 | |
else: | |
return -n |
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
def make_bigger(n: int) -> int: | |
''' | |
post: __return__ != 0 | |
''' | |
return 2 * n + 10 | |
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 typing import List, TypeVar, Union | |
''' | |
Below are some examples of some type limitations of CrossHair using some types. | |
''' | |
############################# | |
# FLOATS | |
############################# | |
def using_float(x: float) -> float: |
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
def make_bigger(n: int) -> int: | |
''' | |
post: __return__ != 0 | |
''' | |
return 2 * n + 10 | |
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
def f1(n: int) -> int: | |
return (n % 2) == 0 | |
def f2(n: int) -> int: | |
if (n == 1000): | |
return 0 | |
else: | |
return (n & 1) == 0 |
NewerOlder