python 学徒活动1(python)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 学徒活动1(python)相关的知识,希望对你有一定的参考价值。
'''Basic Python for Security Professionals'''
def activity01(num1):
'''Return if an input number is Even or Odd'''
if(num1 % 2 == 0):
return "Even"
else:
return "Odd"
def activity02(iv_one, iv_two):
'''Return the sum of two input values'''
return(int(iv_one) + int(iv_two))
def activity03(num_list):
'''Given a list of integers, return how many are even'''
counter = 0
for i in range(len(num_list)):
if(num_list[i] % 2 == 0):
counter += 1
return counter
def activity04(input_string):
'''Return the input string, backward'''
return input_string[::-1]
''' HARDER more INTENSE WAY
counter = len(input_string) - 1
backward_string = ""
while(counter >= 0):
backward_string = backward_string + str(input_string[counter])
counter = counter - 1
return backward_string
'''
def main():
int1 = 3
int2 = 23
int3 = 81
int4 = 18
int5 = 32
str1 = "Backwards"
print activity01(int1)
print activity02(int1, int2)
print activity03([int1, int2, int3, int4, int5])
print activity04(str1)
# main()
以上是关于python 学徒活动1(python)的主要内容,如果未能解决你的问题,请参考以下文章
Python 算法 2022-06-23
[Python爬虫] 之九:Selenium +phantomjs抓取活动行中会议活动(单线程抓取)
向活动对象python搅拌器添加随机颜色
Python urllib2 与保持活动状态
国外线下技术俱乐部建设 - Belgrade Python技术俱乐部2019-01-25活动感悟
[Python爬虫] 之十三:Selenium +phantomjs抓取活动树会议活动数据