Ad
Code
Diff
  • def hello_world(world):
        return "Hello World baby" if world else "No World"
                                                                                                                                                                             
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
    
    
    
    
    • def hello_world(world):
    • if world == True:
    • return "Hello World baby"
    • elif world == False:
    • return "No World"
    • return "Hello World baby" if world else "No World"
Fundamentals
Strings
Code
Diff
  • def reverse_string(string):
        return string[::-1]
    
    
    • def reverse_string(string):
    • reversed_list = [string[letter] for letter in range(len(string) - 1, -1, -1)]
    • return "".join(reversed_list)
    • return string[::-1]
Code
Diff
  • from math import prod as p
    prod = lambda x: p(x)
    • prod = __import__('math').prod
    • from math import prod as p
    • prod = lambda x: p(x)
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda string: string[::-1]
    • reverse_string = lambda string: "".join(reversed(string))
    • reverse_string = lambda string: string[::-1]
Code
Diff
  • class Triangle:
    
        def other_angle(a, b): 
            return 180 - (a + b)
    
        def triangle_type_angle(a, b, c):
            if all( angle < 90 for angle in (a, b ,c)):
                return "Acute Triangle"
            if any(angle == 90 for angle in (a, b, c)):
                return "Right Triangle"
            return "Obtuse Triangle"
        
        def triangle_type_sides(s1, s2, s3):
            if s1 == s2 == s3:
                return "Equilateral Triangle"
            elif s1 == s2 or s2 == s3 or s1 == s3:
                return "Isoceles Triangle"
            return "Scalene Triangle"
            
    
    • class Triangle:
    • def __init__(a, b, c, s1, s2, s3):
    • self.a = a
    • self.b = b
    • self.c = c
    • self.s1 = s1
    • self.s2 = s2
    • self.s3 = s3
    • def other_angle(a, b):
    • return 180 - (a + b)
    • def triangle_type_angle(a, b, c):
    • if all( angle < 90 for angle in (a, b ,c)):
    • return "Acute Triangle"
    • if any(angle == 90 for angle in (a, b, c)):
    • return "Right Triangle"
    • return "Obtuse Triangle"
    • def triangle_type_sides(s1, s2, s3):
    • if s1 == s2 == s3:
    • return "Equilateral Triangle"
    • elif s1 == s2 or s2 == s3 or s1 == s3:
    • return "Isoceles Triangle"
    • return "Scalene Triangle"