def str_int(param1, param2): param1_type = type(param1).__name__ param2_type = type(param2).__name__ if param1_type == 'str' and param2_type == 'int' or param1_type == 'int' and param2_type == 'str': if param1_type == 'int': get_task_result(17, repeat_string(param1, param2)) else: get_task_result(17, repeat_string(param2, param1)) else: if param1_type == 'int' and param2_type == int: get_task_result(17, get_sum(param1, param2)) else: get_task_result(17, param1 + param2)
''' from commonmethods import get_task_description from commonmethods import get_task_result from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(2) put_empty_line() # task 5 get_task_description(5, 'Python Math') a = 1 b = 2 c = a + b get_task_result(5, c) put_empty_line() # task 6 get_task_description(6, 'More Python Math') seconds_in_year = 60 * 60 * 24 * 365 get_task_result(6, seconds_in_year) put_empty_line() # task 7 ''' the final count of grains will be calculated using formula 2 in the power 64 minus 1 ''' get_task_description(7, 'Python Math - Again') totalGrainCount = 0
put_empty_line() import random import math # task1 get_task_description(1, 'Functions') rand_number = random.randint(1, 9) def square(int): return int * int print('Input integer is: ' + str(rand_number)) get_task_result(1, square(rand_number)) put_empty_line() # task 2 get_task_description(2, 'Increment') rand_number = random.randint(0, 1000) def getIncrement(int): return int + 1 print('Input integer is: ' + str(rand_number)) get_task_result(2, getIncrement(rand_number)) put_empty_line()
def isSixGreat(num1, num2): if num1 == 6 or num2 == 6 or num1 + num2 == 6 or num2-num1 == 6 or num1-num2 == 6: get_task_result(5, True) else: get_task_result(5, False)
# SingPath's level_1 task # Implementer: Abilkhayir Akhet from commonmethods import get_task_description from commonmethods import get_task_result from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(1) put_empty_line() # task 1 get_task_description(1, 'Welcome task') get_task_result(1, 'Here I don\'t have to type any code') put_empty_line() # task 2 get_task_description(2, 'Your First Program') greeting = 'Hello World' get_task_result(2, greeting) put_empty_line() # task 3 get_task_description(3, 'Starter Code') bob = 'Thanks for the help' get_task_result(3, bob) put_empty_line() # task 5 get_task_description(5, 'Still more variables') name = 4.27
from commonmethods import get_task_description from commonmethods import get_task_result from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(4) put_empty_line() # task 1 get_task_description(1, 'Find the quotient') def quotient(a, b): return int(a/b) get_task_result(1, quotient(9, 3)) put_empty_line() #task 2 get_task_description(2, 'Find the remainder') def get_remainder(a, b): return int(a%b) get_task_result(2, get_remainder(5,2)) put_empty_line() #task 3 get_task_description(3, 'Check for equality') def isEqual(a, b):
from commonmethods import get_task_result from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(6) put_empty_line() #task1 get_task_description(1, 'Strings') def get_nth_char_in_string(string, index): return string[index] get_task_result(1, get_nth_char_in_string('success', 4)) put_empty_line() #task2 get_task_description(2, 'Hello') def get_greeting(name): return 'Hello ' + name + '!' get_task_result(2, get_greeting('Abilkhayir')) put_empty_line() #task3 get_task_description(3, 'String Slice')
# task 1 get_task_description(1, 'While Loop') def get_sum_using_while_loop(number): count = 0 sum = 0 while (count < number): count += 1 sum += count return sum get_task_result(1, get_sum_using_while_loop(15)) put_empty_line() #task 2 get_task_description(2, 'Sum range') def get_sum_range(numb1, numb2): sum = 0 while numb1 <= numb2: sum += numb1 numb1 += 1 return sum get_task_result(2, get_sum_range(2, 5))
from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(7) put_empty_line() #task1 get_task_description(1, 'Lists') def create_list(): list = [0, 1, [2, 4], 4] return list get_task_result(1, create_list()) put_empty_line() #task2 get_task_description(2, 'List Head') def get_head_of_list(list): return list[0] get_task_result(2, get_head_of_list([1, 6, 23])) put_empty_line() #task3 get_task_description(3, 'List Head & Tail')
В 8 уровне решил не все подряд делать, а выборочно, так как выполнение определенных тасков включает в себе выполнение более ранних тасков ''' from commonmethods import get_task_description from commonmethods import get_task_result from commonmethods import put_empty_line from commonmethods import get_level_number get_level_number(8) put_empty_line() #task1 get_task_description(1, 'Dictionaries') dictionary = {"color": "blue", 7: "seven", 3.14: [3, 1, 4, 6]} get_task_result(1, dictionary) put_empty_line() #task2 get_task_description(2, 'List the keys of a dictionary') def sort_dictioary_keys(dict): return sorted(list(dict.keys())) get_task_result(2, sort_dictioary_keys({'a': 1, 'c': 2, 'b': 3})) put_empty_line() #task3 get_task_description(3, 'Reverse Lookup')