Udemy-100 Days of Code: The Complete Python Pro Bootcamp for 2022
Day1 Working with Variables in Python to Manage Data
1、经典的Hello world!
2、string的叠加
#Day 1 bandname generator
print('hello world!')
city = input('what is your hometown?\n')
pet = input('what is the name of your pet?\n')
bandname = city + ' ' + pet
print("your band name could be",bandname)
#bule color are functions: print,input
#white color are variables: city,pet,bandname
#green color are strings
#purple color are operators
#\n means next line
#2022.10.21 FJ
day2 Understanding Data Types and How to Manipulate Strings
1、数据格式
2、数据格式变化、叠加
#DAY 2 Understanding Data Types and How to Manipulate Strings
#data type
"hello"#string
"123"#string
123#integer
3.14159#float
True/False#boolean
123_456#integer("_"means","so it is 123,456)
#exercise 1 change data type
two_digit_number = input("Type a two digit number: ")
print(int(two_digit_number[0]) + int(two_digit_number[1]))
3+5 #output 8
7-2 #output 5
5*2 #output 10
6/3 #output 2.0(float)
2**3 #output 8
#PEMDAS calculation start from (),**,*,/,+,-
#exercise 2 BMI calculater
height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")
w = float(weight)
h = float(height)
print(int(w /(h * h)))
print(round(2.6666,2))#output: 2.67
print(int(2.6666))#output: 2
print(8//3)#type is integer,output: 2
print(8/3)#type is float,output: 2.677777...
#-=,+=,/=,*=
score += 1
score = score + 1
#line34,35 are the same meaning
#f-string method:simply change all data types into string,love it
score = 100
height = 1.8
iswinning = True
print(f'your score is {score},your height is {height},and your winning is {iswinning}')
#exercise 3 how many weeks you left
age = input("What is your c