🎉 Hello world

This commit is contained in:
2019-12-18 17:30:47 +01:00
commit 95b2aa6c2f
15 changed files with 461 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
def correct_sentence(text: str) -> str:
"""
returns a corrected sentence which starts with a capital letter
and ends with a dot.
"""
return "{}{}.".format(text[0].upper(), text[1:].strip('.'))
if __name__ == '__main__':
print("Example:")
print(correct_sentence("greetings, friends"))
# These "asserts" are used for self-checking and not for an auto-testing
assert correct_sentence("greetings, friends") == "Greetings, friends."
assert correct_sentence("Greetings, friends") == "Greetings, friends."
assert correct_sentence("Greetings, friends.") == "Greetings, friends."
assert correct_sentence("hi") == "Hi."
assert correct_sentence("welcome to New York") == "Welcome to New York."
print("Coding complete? Click 'Check' to earn cool rewards!")

16
Elementary/say-history.py Normal file
View File

@@ -0,0 +1,16 @@
# 1. on CheckiO your solution should be a function
# 2. the function should return the right answer, not print it.
def say_hi(name: str, age: int) -> str:
"""
Hi!
"""
return "Hi. My name is {} and I'm {} years old".format(name, age)
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert say_hi("Alex", 32) == "Hi. My name is Alex and I'm 32 years old", "First"
assert say_hi("Frank", 68) == "Hi. My name is Frank and I'm 68 years old", "Second"
print('Done. Time to Check.')