Liz Krznarich (she/her)
Technical Lead, DataCite
Many tech hats worn! Fullstack engineer, frontend engineer, technical trainer, graphic designer...
Python, Java, JS (Angular/React/Ember), DevOps (Ansible/Terraform/Puppet)
Fun fact: Degrees in Art and Library Science. First professional job involved hot dog ads.
Top general-purpose language in the 2022 StackOverflow developer survey
Top language in the PYPL index
Used by tech giants, including:
What is Python?
Why learn Python?
One way to use Python (repl.it)
Python basics (variables, functions, troubleshooting)
From "The Zen of Python":
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Readability counts.
"Pythonic" = code that’s easy to read, follow and understand
Key difference from other languages: whitespace is significant!
Statements _must_ be indented
def add_numbers_between(start, end):
sum = 0
for n in range(start, end):
sum += n
return n
add_numbers_between(5, 10)
Python is "multi-paradigm" and supports a variety of programming approaches:
Python standard library includes everything you need for common tasks:
Can't find what you need in the Python Standard Library? There's probably a package for that!
Popular, well-maintained frameworks available for quickly building web apps
Often used to build REST APIs, which can be connected JS frontends, but can also serve frontend via a template system
We'll use Replit for our coding exercises in this class.
#print "Hello World" to the screen
print("Hello World")
#use input() to ask users to provide input
input("What is your name? ")
#this is a string
print(type("Hello World"))
#this is a integer (no decimals)
print(type(3))
#this is a float (decimal places)
print(type(3.1))
#assign a name to a literal value
my_var = "foo"
#assign a name to an input value
user_name = input("What is your name? ")
first_name
rather than fn
#you can create functions to do a specific task
def add(x, y):
answer = x + y
print(answer)
add(2, 3)
Create a function called "mult" that multiplies two numbers and prints the answer to the screen.
Use your new function to find the answer to 12345 * 6789 = ?
#boolean data types are True/False
a = True
print(type(a))
b = False
print(type(b))
#boolean expressions evaluate to True or False
a = 1
b = 2
print(a > b) #is a greater than b?
print(a < b) #is a less than b?
print(a == b) #is a equal to b?
print(a != b) #is a not equal to b?
#you can have your code make choices with if, else
a = 1
b = 2
if a == b: #if the statement evaluates to True
print("a is equal to b")
else: #if the statement evaluates to False
print("a is not equal to b")
#if, else statements with strings
day = "Friday"
if day == "Friday":
print("Happy Friday!")
else:
print("Have a good day!")
def hello(day):
print("Happy "+ day)
if day == "Friday":
print("It's almost the weekend!")
else:
print("Have a good day!")
hello("Saturday")
hello("Friday")
#list can hold multiple elements of different types
my_list = ["hello", 1, 3.5]
#lists start at 0
my_list[0]
#how many elements are in my list?
print(len(my_list))
def hello(day):
print("Happy "+ day)
if day == "Friday":
print("It's almost the weekend!")
elif day in ["Saturday", "Sunday"]:
print("Woohoo! It's the weekend!")
else:
print("Have a good day!")
hello("Saturday")
hello("Friday")
hello("Tuesday")
def hello(day):
print("Happy "+ day)
if day == "Friday":
print("It's almost the weekend!")
elif day in ["Saturday", "Sunday"]:
print("Woohoo! It's the weekend!")
else:
print("Have a good day!")
hello("saturday")
def hello(day):
print("Happy "+day+"!")
#change day into all lowercase
day = day.lower()
if day == "friday":
print("It's almost the weekend!")
elif day in ["saturday", "sunday"]:
print("Woohoo! It's the weekend!")
else:
print("Have a good day")
hello("saturday")
hello("FRIDAY")
Join us for our Python 1 class series starting next week!