Hello everyone! I hope you all had a great first class. Here is your first homework assignment. Solutions will be posted later this week. Let us know if you get stuck on something and need some help.
Homework:
Giver 3 examples of each data type (2 for Boolean)
Create the variables name, grade, color, and another variable for something you like. Use f-strings/concatenation to print the following string but with your information:
Shravya is in 11th grade, and her favorite color is blue.
Shravya's favorite movie is Thor: Ragnorok.
Resources:
Class slides: https://docs.google.com/presentation/d/198KFEj0Y9F2lbD_pV5QoxOBBly_hCVr_zYyoJ_kBrnM/edit?usp=sharing
Class code: https://replit.com/@ShravyaS/IntroToPython-Class1#main.py
Discord: https://discord.gg/28D6hGXP
Contact info:
shravyassathish@gmail.com (mentor)
kingericwu@gmail.com (TA)
felixguo41@gmail.com (TA)
int ex: 1,2,3
string ex: "ethan", "box", "lamp"
float ex: 9.23, 5.24, 7.27
boolean ex: true, false
name = "ethan"
grade = "7th"
color = "orange"
favorite sport = "volleyball"
print (f'{name} is in {grade} and his favorite color is {color}, his favorite sport is {favorite sport}')
strings = ["hello", "ajhsdkofhioqwpherjnjkbn .,xmznclkhfoiweuriya ruithgajkhdfjkasdhjasd", "Wow this is a very cool sentence, which is also a string!!!"]
ints = [42, -69, 212365489741230165789798405634135403124654654]
floats = [42.0, -0.69, 2123654897412301657.89798405634135403124654654]
booleans = [True, False]
print(f'The data types are: strings, which include {strings}, integers, which include {ints}, floats, which include {floats}, and booleans, which are only {booleans}\n\n\n')
name = "Christopher"
grade = 9
color = "teal"
something = "coding language"
favoritesomething = "Python"
print(f"{name} is in grade {grade}, with a favorite color of {color}. \n{name}'s favorite {something} is {favoritesomething}")
print(type(False))
print(type(True))
print(0.5)
print(0.10)
print(9)
print(10)
print("hello")
print("goodbye")
grade = "9th grade"
print(f'I am in {grade}')
show = "A Business Proposal"
print(f'My favorite TV show is {show}')
1.
String: "Hi", "Bye", "See you"
Int: "5" , "10" , "7"
Float: "3.10298478314", "5.124214214" , "9.8"
Boolean: "True", "False"
2.
name="Crystal"
grade="6th"
color="pink"
book_series="Harry Potter"
print (f'{name} is in {grade} grade and their favorite color is {color}. Their favorite book series is {book_series}')
When to use f(‘ ‘) versus f(““)?
#string: "ha" "bruha" "oha"
#integer: 8, 7 , 91
#float: 2.1, 6.01, 6.17
#boolean: True, False
name="Brian"
grade=8
color="light blue"
favGame="VALorant"
print(f'My name is {name}, I am in grade {grade}.')
print("My fav color is " + color + "and my fav game is " + favGame)
Str: "hello", "goodbye", "platypus"
int: 5, 89, 32
float: 0.5, 0. 7, 6.2
Bool: true, false
name = "Joanna"
grade = 3
color = "blue"
animal = "platypus"
print (f"{name} is in {grade}rd grade, and her favorite color is {color}.")
print (f"{name}'s favorite animal is a {animal}.")
Str: "hi", "bye", "bed"
int: 1, 72, 36
float: 0.75, 0.0456, 0.8645
Bool: true, false
name="Marcus"
grade="6"
color="green"
favouritemovie="fast and furious 8"
print(f'{name} is in {grade} grade, and his favorite color is {color}.')
print(f"{name}'s favorite movie is {favmovie}.")
#int example: 1,3,2 #str example: hello,hockey,yes,no #:bool example: True, False #float example: 0.1,0.2,0.3 name="William" grade="8th" color="Green" favoritemovie="Rise of Gru🤵" print(f'{name} is in {grade} grade, and his favorite color is {color}.') print(f"{name}'s favorite movie is {favoritemovie}.")
a = 12
b = 2
c = 18
print(a, b, c)
f = "welcome"
g ="book"
h = "videogames"
print(f, g, h , sep = ',')
print(False)
print(True)
i = 0.1
j = 0.9
k = 38.4
print(i, j, k, sep = ', ')
name = "Eugene"
grade = "9th grade"
color = "blue"
movie = "Avengers Endgame"
print(f'{name} is in {grade}, and his favorite color is {color}.\nHis favorite movie is {movie}')
Homework solutions:
Str: "hello", 'blue', '"hi"'
Int: 90, -2, 0
Float: 90.0, 3.1415, -0.4
Bool: True or False
name="Eric"
grade="9th"
color="blue"
favmovie="Iron Man"
print(f'{name} is in {grade} grade, and his favorite color is {color}.')
print(f"{name}'s favorite movie is {favmovie}.")