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.
Ints: 7, 1000000, and 15. Floats: 12.756, 0.1, and 10.981. Strings: "I'm hungry", "Tomato's", and "Cats are cool".
title = "Ms."
name = "person"
print("hello", title, name)
Integers, (1,3,7)
1.3, 3.7 1.337
"genius", "heckerpro", "1337aboveyou
me= "prohecker"
1337=moi
print("me","1337")
intigers 100000000000000000000000000000000000000000000000000000 , 10000000000000000000000000000000000000000000000000000000000000000,100000000000000000000000000000000000000000000000000000000000000
the best varible is a string Title="Fat"
name="Joe liama"
print("Hello",title,name)
1. Integers:3,4,5
Floats:1.2,3.4,5.678910
Strings: “Happy”, “One hundred seventy two”, “Hello, nice to meet you.”
2.The best variable type to use here is a string.
Title=“Sir”
Name=“Braginski”
print(“Hello,”,title,name)
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)
1. Integer: 7, 4, -3; Float: 1.5, 4.6, 10.99; String: "Whale", "human", "Monkey"
2. title = "Sir"
name = "Lancelot"
print("Hi", title, name)
-3, 5, 8; 1.1, 2.4, 4.7; "Dog", "Bird", "Smart boy"
String as data type
title = "Mr." name = "Yuki" print("Hello,", title, name)