This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "Ventsi" # Global variable | |
def sum_numbers(number1, number2): | |
greting = "Hi, " + name # greeting is a local variable | |
sum_result = number1 + number2 # sum_result local variable | |
result = greting + " the sum is " + str(sum_result) # str() is a bult-in function | |
return result | |
print(sum_numbers(10, 5)) | |
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_numbers(number1, number2): | |
result = number1 + number2 | |
return result | |
print(sum_numbers(10, 5)) | |
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def get_current_datetime(): | |
""" | |
Returns the current date and current time as a 2-tuple | |
""" | |
current_datetime = datetime.datetime.now() | |
current_date = current_datetime.date() | |
current_time = current_datetime.time() | |
return (current_date, current_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def get_current_datetime(): | |
current_datetime = datetime.datetime.now() | |
current_date = current_datetime.date() | |
current_time = current_datetime.time() | |
return (current_date, current_time) | |
date, time = get_current_datetime() | |
print(date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
book = {(1, 10): "Introducton", (11, 15): "Notation and Definitions", (16, 30): "Fundamental Algorithms"} | |
print(book[(1, 10)]) | |
book = {[1, 10]: "Introducton", [11, 15]: "Notation and Definitions", [16, 30]: "Fundamental Algorithms"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
print(timeit.timeit("x = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)", number = 1000000)) | |
print(timeit.timeit("x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", number = 1000000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_skills = ["Communication", "Courtesy", "Flexibility", "Integrity", "Responsibility"] | |
list_skills[0] = "Flexibility" | |
print(list_skills) | |
tuple_skills = ("Communication", "Courtesy", "Flexibility", "Integrity", "Responsibility") | |
tuple_skills[0] = "Flexibility" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b, c, d = (10, 20, 30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b = (10, 20, 30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b, c = (10, 20, 30) | |
print(a) | |
print(b) | |
print(c) |