Day5 Python基础语法三

今天的影片内容为介绍之後程序设计不可或缺的if else 以及for回圈,千万别错过呦~

以下为影片中有使用到的程序码

#印出串列中的元素
animals = ["elephant","monkey","jellyfish"]

for animal in animals:
    print(animal)

#印出字串
for w in "Hello":
   print(w)

#印出范围中的数字
for i in range(5):  #[0,1,2,3,4]
    print(i)

for i in range(1,10,2):
    print(i)
#if叙述
if True:
    print("True")
else:
    print("False")
    
#多重条件判断
price = 40

if price >= 90:
    print("太贵了")
    
elif price >= 70:
    print("价格普通")
    
elif price >= 60:
    print("价格便宜")

else:
    print("太便宜了")

#加入复合式条件
level = 1
point = 100

if level == 2 and point == 100:
    print("可兑换A")
if level == 2 or point == 100:
    print("可兑换B")
#比较运算子
a = 10
b = 20

#a是否小於b
print("1:",a < b)

#a是否小於等於b
print("2:",a <= b)

#a是否大於b
print("3:",a > b)

#a是否大於等於b
print("4:",a >= b)

#a是否等於b
print("5:",a == b)

#a是否不等於b
print("6:",a != b)

如果在影片中有说得不太清楚或错误的地方,欢迎留言告诉我,谢谢您的指教。


<<:  Day 5 - Using Argon2 for Password Verifying with ASP.NET Web Forms C# 使用 Argon2 验证密码

>>:  Day 7 到底有没有被激励到?

[Day 10] 前端页面路由设定 vue-router

开始动工啦~ 今天电脑不在手边,这篇会先在CodeSandBox实作 所以介面会长的跟上一篇的Web...

Day 07 CSS <字体属性>

CSS Fonts(字体) 属性 用於定义字体系列、大小、粗细 和文字样式(ex:斜体) 1.字体系...

Day11 测试写起乃-FactoryBot-create、build、build_stubbed

建立bot 官方文件有说有以下建立方式至於差别在哪呢? # Returns a User insta...

视觉化KBARS(4)-controller

今天要来写controller的部分, (1)controller新称showOneMinKbar方...

[Day21] 在 .NET 使用 Dapper 操作 MySQL

现在我们的资料库已经就绪了,我们赶快来透过 .NET Web API 操作资料库吧! 现在写 .NE...