zoukankan      html  css  js  c++  java
  • python 小练习1

    _input = ['I',6,6,'love','python',6]


    _str = '' _sum = 0 for item in _input: if isinstance(item,str): _str += item _str += ' ' elif isinstance(item,int): _sum += item else: print('nothing') print(_str) print(_sum)

    实现输出2-3+4-5+6.....+100

    _sum = 0
    for item in range(2,101):
        if item % 2 == 0:
            _sum += item
        else:
            _sum -= item
        
    print(_sum)

     使用while循环输入 1 2 3 4 5 6     8 9 10

    i = 0
    
    while i < 10:
        i += 1
        if i ==7:
            continue
        else:
            print(i)

     

    #coding:gbk
    
    f = open(r'C:UsersMartinDesktoppython_class_members.txt')
    
    content = f.readlines()
    
    while True:
        _input = input('pls input your choise:')
        if _input == 'all':
            for line in content:
                print(line)
        elif _input in ['quit','exit','q']:
            exit()
            
        elif "-" in _input:
            prefix,suffix = _input.split('-')
            for line in content[int(prefix) - 1:int(suffix)]:
                print(line)
        
        elif _input not in str(content):
            print('sorry, your input is not in search')
        
        
        else:
            for item in content:
                if _input in item:
                    print(item)

     

  • 相关阅读:
    OSCache使用指南
    sql性能优化浅谈
    Oracle SQL性能优化
    SQL性能优化
    Linux/Unix笔记本
    Linux/Unix笔记本
    LUOGU P3413 SAC#1
    poj 2393 Yogurt factory(贪心)
    poj 2431 Expedition (贪心)
    LUOGU P3161 [CQOI2012]模拟工厂 (贪心)
  • 原文地址:https://www.cnblogs.com/hellojackyleon/p/8705640.html
Copyright © 2011-2022 走看看