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

python 语言基础1(自学)2022.3.6

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

python 语言基础1(自学)2022.3.6

学习目标:

1. Hello World

2.字符串(String)

3.数字(number)

4.注释(marking)

5.禅(import)


学习内容:

Python基本语法(Python 编程从入门到实践 第二章)


学习时间:

11:30


学习产出:

1.文件“Hello World”

print ("你好,世界")

print("Hello Python world!")

message="Hello python world!"

print(message)

 output

你好,世界
Hello Python world!
Hello python world!

 2.文件“String”

message='This is a string'

message2="This is a string"

name="yuchiYixuan yuchi"

print(name.title())#所有的首字母大写

print(name.upper())#所有的字母大写

print(name.lower())#所有的字母小写

surname="yuchi"

firstname="yixuan"

fullname=surname+" "+firstname

print(surname+firstname)#用加号进行字符串合并

print(surname+" "+firstname)

print(fullname)

a="Python"

b="C"

c="java "

print("t"+a+"t")#t制表符,缩进

print("Language:n"+a+"n"+b+"n"+c)#n制表符,换行

print("Language:nt"+a+"nt"+b+"nt"+c)

print(c+b)

print(c.rstrip()+b)#删除空白

sentence="I don't like you"#若外引号改成单引号会报错

 output

Yuchiyixuan Yuchi
YUCHIYIXUAN YUCHI
yuchiyixuan yuchi
yuchiyixuan
yuchi yixuan
yuchi yixuan
    Python    
Language:
Python
C
java 
Language:
    Python
    C
    java 
java C
javaC

3.文件“Number" 

print(2+3)

print(3-2)

print(2*3)

print(3/2)

print(2+3*4)

print((2+3)*4)

print(0.1+0.1)

print(2*0.2)

print(0.1+0.2)

age=23

message="Happy "+str(age)+"rd Birthday"#In Python, the type of data should be the same, use str() to transform the number to string

print(message)

output

5
1
6
1.5
14
20
0.2
0.4
0.30000000000000004
Happy 23rd Birthday

文件"Marking&import" 

 

import pandas as pd

import this

#Hi Python(单行注释)
'''
hfjahjd
sdsdsff
dsfsdfsdf
fds
'''#多行注释
print("hello world")

print(pd.read_csv)

print(this)

 output

 

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
hello world

认真理解,python的禅,对以后编程有很大好处 

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

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

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