Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random
- VALUE = 1
- BIN_OP = 2
- FN = 3
- ASS = 4
- DOT = 5
- # Code formats
- code_format = {
- VALUE: '{}',
- BIN_OP: '{} {} {}',
- FN: '{}({})',
- ASS: '{} = {}',
- DOT: '{}.{}'
- }
- # Binary Operations
- bin_ops = [
- '+',
- '-',
- '*',
- '/',
- '%',
- '//',
- '**',
- ]
- # I recommend that you add more words to this array
- # Preferably technical terms like "Abstraction" or "Parser" or hackerman stuff idk lol
- code_dictionary = [
- 'thingy',
- 'var',
- 'foo',
- 'bar',
- 'something'
- ]
- def generate_random_int(min_int, max_int):
- return min_int + (random() * (max_int - min_int))
- something = None
- # Complete this recursive function
- # Replace <something> with what it should return - a string.
- # Hint 1: You'll be calling generate_random_int() a lot
- # Hint 2: Work your way inside out.
- def generate_code(nest_depth: int):
- if nest_depth <= 1:
- # Return a value (int, float, bool) or a variable ()
- return something
- else:
- # if-elif statements depending on the generated random number
- return something
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement