Python Bytes Lesson Six: Functions

preview_player
Показать описание
What's up, coding experts!👋🏼

Welcome to Lesson Six of Python Bytes. Today, you will learn about functions- a function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function 🧠

Click on the link for Burk's GetList Function

Happy coding! 👩🏽‍💻💡👨🏻‍💻

Links:

Materials Needed: PC, MAC, Chromebook, or tablet 💻
Experience Required: None!
Suggested Age: 8+

________________________________________________________________________________________________
Let us know in the comments section below what you enjoy and what we can improve, so that we can tailor our lessons to best help YOU👍🏼

Рекомендации по теме
Комментарии
Автор

Lesson 5 Homework

# Writes a list to a file

fruit = ["apples", "oranges", "pears", "grapes", "bananas", "snozberries"]

myfile = open("myfile.txt", "w")

for x in range(0, len(fruit), 1):
myfile.write(fruit[x]+" ")
myfile.close()

myfile = open("myfile.txt", "r")

contents = myfile.read()
print(contents)


# BONUS
# .join() turns a list into a string.
# Specify the separator character
# BEFORE .join() - like this:
# print(", ".join(fruit))

# We create a variable called joinedFruit
# and join the list items into it

'''
joinedFruit = ", ".join(fruit)

myfile = open("myfile.txt", "w")
# Then we write joinedFruit to the file
myfile.write(joinedFruit)
myfile.close()

myfile = open("myfile.txt", "r")

contents = myfile.read()
print(contents)
'''

burkmurray