Skip to content

Instantly share code, notes, and snippets.

@codetombomb
codetombomb / settings.py
Created September 26, 2020 01:15
Adding an App to settings.py file
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'projects',
]
@codetombomb
codetombomb / hello_world.py
Created September 24, 2020 19:09
Provide arg with default value
def introduction_with_language(name, language = "Python"):
print(f"Hi, my name is {name} and I am learning to program in {language}.")
if __name__ == "__main__":
introduction_with_language("Tom", "Ruby")
@codetombomb
codetombomb / hello_world.py
Last active September 24, 2020 19:06
Parameter default
def introduction_with_language(name, language = "Python"):
print(f"Hi, my name is {name} and I am learning to program in {language}.")
if __name__ == "__main__":
introduction_with_language("Tom")
@codetombomb
codetombomb / default_values.py
Created September 24, 2020 19:05
Params Default Values
def introduction_with_language(name, language = "Python"):
print(f"Hi, my name is {name} and I am learning to program in {language}.")
if __name__ == "__main__":
introduction_with_language("Tom")
@codetombomb
codetombomb / hello_world.py
Last active September 24, 2020 19:01
Multiple Params
def introduction_with_language(name, language):
print(f"Hi, my name is {name} and I am learning to program in {language}.")
if __name__ == "__main__":
introduction_with_language("Tom", "Python")
@codetombomb
codetombomb / hello_world.py
Created September 24, 2020 18:30
enumerate
def print_days():
days_of_week = ["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"]
for i, d in enumerate(days_of_week):
print(i, d)
if __name__ == "__main__":
print_days()
@codetombomb
codetombomb / hello_world.py
Last active September 24, 2020 18:51
Index in list
days_of_week = ["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"]
first_index = days_of_week[0]
print(first_index)
@codetombomb
codetombomb / hello_world.py
Created September 24, 2020 18:11
Index in List
days_of_week = ["Mon", "Tues", "Wed", "Thurs", "Fri", "Sat", "Sun"]
days_of_week[0]
@codetombomb
codetombomb / hello_world.py
Created September 24, 2020 17:34
For loop
def for_loop():
the_list = [1, 2, 3, 4, 5]
for each_individual_value in the_list:
print(each_individual_value)
if __name__ == "__main__":
for_loop()
@codetombomb
codetombomb / hello_world.py
Created September 24, 2020 17:18
While Loop
def while_loop():
x = 0
while x < 5:
print(x)
x += 1
if __name__ == "__main__":
while_loop()