zoukankan      html  css  js  c++  java
  • 003 Python与类C语言的区别(未完)

    #写在前面的话:重点记录Python的特点

     Python特点:

    1. 无分号断句

    2. 不用担心溢出问题

    3. if-else的用法不同

    #if或else后面都要添加冒号:
    
    import random
    secret = random.randint(1,10)
    
    print('-----我爱鱼C工作室-------')
    temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字(3次机会):")
    guess = int(temp)
    cnt = 1
    
    if guess == secret:
        print("我靠,你是小甲鱼心里的蛔虫吗?!")
        print('哼,猜中了也没有奖励!')
    else:
            if guess > secret:
        #检查标点符号,英文的冒号
                print("哥,大了大了~~~")
            else:
                print("嘿,小了,小了~~~")
                
    while guess != secret and cnt < 3:
        temp = input(" 不好意思,猜错了,重新输入吧:")
        guess = int(temp)
        cnt = cnt + 1
        if guess == secret:
            print("我靠,你是小甲鱼心里的蛔虫吗?!")
            print('哼,猜中了也没有奖励!')
        else:
            if guess > secret:
        #检查标点符号,英文的冒号
                print("哥,大了")
            else:
                print("嘿,小了")
    print("游戏结束,不玩啦^_^")
        

    4.”与或非“直接用英文

    与:and        (C++: &&)
    或:or         (C++:||)
    非:not        (C++: !)
    def BooleanNOT(x):
        # not x
        if x:
            return False
        else:
            return True
    
    
    def BooleanOR(x, y):
        # x or y
        if not x:
            return y
        else:
            return x
    
    def BooleanAND(x, y):
        # x and y
        if not x:
            return x
        else:
            return y

    5.留白

  • 相关阅读:
    练习5
    图例设置了却不显示
    easyui中多级表头,主表头不能添加field字段,否则不居中
    springboot热部署
    ReactDom.render调用后没有渲染
    webpack打包配置模板
    overridePendingTransition
    multiDex分包时指定主dex的class列表
    android实现手势锁
    动态补丁构建工具nuwa中的“坑”
  • 原文地址:https://www.cnblogs.com/paulprayer/p/10366882.html
Copyright © 2011-2022 走看看