Day1-Day3 python入门100天Udemy训练营

这篇博客介绍了在Udemy的Python专业速成营中,前三天的学习内容,包括变量管理数据、数据类型与字符串操作、控制流和逻辑运算符,如条件语句、整除判断以及f-string的使用,并提到了ASCII ART和draw.io作为辅助学习工具。
摘要由CSDN通过智能技术生成

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值