#100DaysOfCode: Python Day 8

#100DaysOfCode: Python Day 8

Functions With Inputs

ยท

2 min read

#100DaysOfCode Day 7

๐Ÿ” I CREATED MY OWN MESSAGE ENCRYPTION using the Caesar Cipher! ๐Ÿ”
CLICK HERE and press "Run" to try it out.
Screenshot 2021-05-18 at 18.09.07.png

Yesterday I learned how to create functions with inputs. My python code can become a lot more readable and cleaner now.
Knowing C# has been a huge advantage for me on this course. As I get more comfortable with Python syntax and standards, I relate it to the "equivalent" languages I know, making me breeze through the lessons.

Lessons

  1. It's easy to pick up and learn a new programming language if you already know how to code in another programming language.

TO THE CODE!!!

functionsWithInputs.py

# Functions

# def my_function():
#     #Do this
#     #Then do this
#     #Finally do this

# Functions With Inputs

# def my_function(something):
#     #Do this something
#     #Then do this
#     #Finally do this

def greet():
    print("Hi")
    print("How are you?")
    print("Isn't the weather nice today?")

def greet_with_name(name):
    print(f"Hi {name}")
    print(f"How are you {name}?")
    print("Isn't the weather nice today?")

def greet_with(name, location):
    print(f"Hi {name}")
    print(f"What is it like in {location}?")

greet()
# OUTPUT
# Hi
# How are you?
# Isn't the weather nice today?

greet_with_name("Rishal")
# OUTPUT
# Hi Rishal
# How are you Rishal?

# Positional Arguments - order matters
greet_with("Rishal", "Nowhere")
# OUTPUT
# Hi Rishal
# What is it like in Nowhere?

# Keyword Arguments - you assign the arguments explicitly
greet_with(name="Rishal", location="Nowhere")
# OUTPUT
# Hi Rishal
# What is it like in Nowhere?

The challenge to create that message encryption and decryption app made me think out of the box. I say this because the instructor has a different way of thinking than me, which means that I am exposed to other ways to solve the given problem, which is even more valuable than learning the syntax ๐Ÿคฏ. I am excited to progress in this course.