Python学习第一天

一、python集成开发环境Anaconda的安装

网址:https://blog.csdn.net/z2858539804/article/details/81407456?tdsourcetag=s_pcqq_aiomsg

二、python开发软件PyCharm的安装

注册码的获取:http://idea.lanyus.com

三、练习基本语法

1.1if判断

代码块


age=input('是否成年')

age=int(age)

if number>=18:

print('成年')

else:

print('未成年')

2、计算 1 ~ 100之间的累加和

i = 1

sum_num = 0

while i <= 100:

# sum_num = sum_num + i

sum_num += i

i += 1

print(sum_num)

3、跳出循环break

i=1
sum = 0
while i <= 100:
sum += i
if sum > 1000:
breaki += 1
print(sum)

4、计算所有奇数的和

i = 1
sum = 0
while i <= 100:
% 取模  
//整除
if i % 2 == 0:
i += 1
continuesum += i
i += 1
print(sum)

你可能感兴趣的:(Python学习第一天)