栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

学习报告01

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

学习报告01

本周学习的课程为python核心基础语法中的数据类型与方法,共三节课。

第一节课主要学习了print的一些用法,语法比较基础

作业:自动生成一段相亲介绍

name = input('您的姓名是:')
age = input('您的年龄是:')
hometown = input('您的家乡是:')
work = input('您的工作是:')
wages = input('您的收入是:')
gender = input('您的性别是:')
gender2 = "男"
gender3 = "女"
print("已为您生成相亲自我介绍:")
if gender == gender2:
    print("亲爱的女士,本人为人类高质量男性{name},今年{age}岁,家住{hometown},现在的工作是{work},收入有{wages},很希望与您见一面,希望得到您的同意")
elif gender == gender3:
    print("亲爱的先生,本人为人类高质量女性{name},今年{age}岁,家住{hometown},现在的工作是{work},收入有{wages},很希望与您见一面,希望得到您的同意")
else:
    print("别闹,搁着装外星人")
    

第二节课学习了流程控制,对各种运算符有了理解除了基础的运算符,也了解到了计算机语言中与平时理解不同的运算符。

另外还学习了条件判断语句,如if条件语句,while语句等

i = 1
j = 0
while i <= 100 and j < 20:
    if i % 2 == 0:
        print(i)
        j += 1
    i += 1
import random
ticket = 1
money = 1000
security = random.randint(0, 2)

if ticket != 1:
    print("车票已售罄")
else:
    if money < 100:
        print("用户余额不足")
    else:
        if security != 0:
            print("携带危险物品禁止上车")
        else:
            print("购票成功,请上车")
import random
ticket = 1
money = 1000
security = random.randint(0, 2)

if ticket != 1:
    print("车票已售罄")
else:
    if money < 100:
        print("用户余额不足")
    else:
        if security != 0:
            print("携带危险物品禁止上车")
        else:
            print("购票成功,请上车")
i = 1
while i <= 9:
    j = i
    while j <= 9:
        print("{}*{}={} ".format(i, j, i*j).ljust(2), end="")
        j += 1
    print("")
    i += 1

到这里已经能感受到计算机语言的魅力了

第三节课对字符串的用法进行了学习熟悉,这也是我对python感触最大的一节课。这节课开始接触python库的用法,也正式开始接触python庞大的数据量。

txt1 = "The Fisherman and The Little Barracuda"
txt2 = "渔夫和小梭鱼"
txt3 = "The fisherman casts the net into the sea and catches a little barracuda. "
txt4 = "渔夫把网撒到海里,捕到了一条小梭鱼。"
txt5 = "The pitiful fish asks the fisherman to release it。"
txt6 = "那可怜的小鱼求渔夫放了它。"
txt7 = "I am still young.He says:If you catch me after I am an adult, it is better for you."
txt8 = "他说:“我还太小。”他又说:“如果你把我放了,等我长大后再来抓我,那对你会有更大的好处!”"
txt9 = "The fisherman says: IfI giveup the present small profit to seek an uncertain future large one, am I not a fool?"
txt10 = " 渔夫说:“如果我现在放弃手上已经得到的小利而去追求那些虚无渺茫的大利,那我岂不成了傻子了吗?”"
txt11 = "This story means:only foolish man will giveup the litterprofit which he has seekuncertain future large profits"
txt12 = "这个故事说明,愚蠢的人才会放弃已到手的小利,而去追求那些虚无的大利。"
print(len(txt1))
print(len(txt2))
print(txt3)
print(txt4[5])
print(txt5[2: 4])
print(txt6[2: -1])
print(txt7[6: len(txt7)])
print(txt8[::-1])
print(txt9[290])
print("and" in txt1)
print("and" in txt2)
txt1.find("and")
txt1.rfind("and")
txt3.count("the")
txt1.startswith("The")
txt1.endswith("The")
"asdasd".isalpha()
"123123".isdigit()
"aydb@832749".isalnum()
"ohhhhhh".rjust(50)
"ohhhhhh".ljust(50)
"ohhhhhh".center(50)

以上只是冰山一角,不得不说python的功能确实强大,也让我开始感受到python与其他语言的不同之处。python在功能强大的同时,也带来了一些学习的不便,如需要的功能理解不足就会导致运行结果与意想中相差甚远,在其他语言中对代码的微笑调整在python中也许就要查询较多的资料。

目前来说,我对自己的学习进度还算满意,希望自己可以坚持下去。

最后感谢蓝桥老师随时都在的即使答疑,对我的python学习起了巨大帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/768942.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号