Hi everyone, hope you had a great first class!
RESOURCES:
Class slides: https://docs.google.com/presentation/d/1QYxtxPQ2aYn4e7HWUbLPgZIO43LFtU6Tu8G8GVM7BlE/edit?usp=sharing
Example code: https://replit.com/@ShravyaS/IntroToPython
Coding platform: replit.com
Join the Discord (if you can): https://discord.gg/Am6Y3r2y
(You can always ask for help under #intro-python)
In addition, here's a quick recap:
- Python is a programming language that's readable and user-friendly.
- In repl.it, the left side is the editor and the right side is the console. Code goes in the editor, output in the console.
- Variables are like a box that contain values.
- Datatypes are types of values, and they include strings, ints, floats, booleans, and more.
- Strings = chain of characters (ex: "Hello!")
- Integers = numbers (ex: 9)
- Floats = decimals (ex: 2.5) - Boolean = True or False
- Variables can be created, reassigned, or printed (with other values, too.)
HOMEWORK:
1. Give 3 examples each (different from the slides) of integers, floats, and strings. (9 in total.)
2. Write a program that stores 2 variables: a title (like "Sir" or "Mr.") and a name. What data type is best to use for these two variables? Have the program print out "Hello, {title} {name}"
Post your answers as a comment! We'll post solutions before next class.
Hi everyone, here are some possible solutions to the homework
1. Integers: 3, 4, -8
Floats: 1.2, 4.8, -8.0
Strings: "Happy", "13", 'Hi, how are you?'
2. The best variable type to use here is a string
title = "Mr."
name = "Smith"
print("Hello,", title, name)