def Greeting(n, rank='', formal=0): greeting_word = "Hello" if formal else "Hey" rank_str = f", {rank}" if rank and formal else ',' period = '.' if formal else '!' return f"{greeting_word}{rank_str} {n}{period}"
Greeting=lambda n,rank='',formal=0:f"He{['y','llo'][f:=formal]},{rank*f and' '+rank} "+n+'!.'[f]- def Greeting(n, rank='', formal=0):
- greeting_word = "Hello" if formal else "Hey"
- rank_str = f", {rank}" if rank and formal else ','
- period = '.' if formal else '!'
- return f"{greeting_word}{rank_str} {n}{period}"
Fundamentals
Logic
def identify_data_type(n): return type(n).__name__
exec(__import__("marshal").loads(__import__("codecs").decode("63000000000000000000000000000000000200000040000000730c0000006400640184005a0064025300290363010000000000000000000000010000000200000043000000730a00000074007c0083016a01530029014e2902da0474797065da085f5f6e616d655f5f2901da0576616c7565a9007203000000fa083c737472696e673eda083c6c616d6264613e0100000073020000000a0072050000004e29015a126964656e746966795f646174615f747970657203000000720300000072030000007204000000da083c6d6f64756c653e0100000073020000000c00","hex")))- def identify_data_type(n):
- return type(n).__name__
Fundamentals
Strings
def reverse_string(s): return s[::-1]
exec(__import__('marshal').loads(bytes.fromhex("e30000000000000000000000000100000000000000f30c0000009700640084005a00640153002902630100000000000000000000000400000003000000f31800000097007c00640064006401850319000000000000000000530029024ee9ffffffffa9002901da0461726773730100000020fa083c737472696e673eda015f7207000000020000007311000000800090449814981498329814944ad00d1ef3000000004e29017207000000720400000072080000007206000000fa083c6d6f64756c653e7209000000010000007314000000f003010101e0001ed0001ed0001ed0001ed0001e7208000000")))- def reverse_string(s):
- return s[::-1]
import codewars_test as test from solution import reverse_string @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals(reverse_string('abc'), 'cba') test.assert_equals(reverse_string('123'), '321') test.assert_equals(reverse_string('a1b2c3'), '3c2b1a') test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH') test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
- import codewars_test as test
from solution import _ as reverse_string- from solution import reverse_string
- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
- test.assert_equals(reverse_string('abc'), 'cba')
- test.assert_equals(reverse_string('123'), '321')
- test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')
- test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')
- test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
if world is True, result is "Hello, World".
if world not True, result is "Goodbye, World".
def hello_world(world): return "Hello, World" if world == True else "Goodbye, World"
exec(__import__("marshal").loads(__import__("codecs").decode("63000000000000000000000000000000000200000040000000730c0000006400640184005a006402530029036301000000000000000000000001000000020000004300000073100000006401640267027c00190064031700530029044e5a07476f6f646279655a0548656c6c6f7a072c20576f726c64a9002901da016972000000007200000000fa083c737472696e673eda083c6c616d6264613e020000007302000000100072030000004e29015a0b68656c6c6f5f776f726c647200000000720000000072000000007202000000da083c6d6f64756c653e0100000073020000000c01","hex")))- def hello_world(world):
- return "Hello, World" if world == True else "Goodbye, World"