zoukankan      html  css  js  c++  java
  • Introduction to Computer Science and Programming in Python chap2

    Branching and iteration

    Strings

    concatenate the strings

    hi = "hellothere"
    name = "ana"
    oscar = hi + name  
    print(oscar)
    ppi = hi+" "+name
    print(ppi)
    
    hellothereana
    hellothere ana
    

    Input/output

    cast ( ightarrow) strings

    text = input("Type anything... ")
    print(5*text)
    num = int(input("Type a number... "))
    print(5*num)
    
    Type anything... 4
    44444
    Type a number... 22
    110
    

    COMPARISON OPERATORS ON int,float,string

    while LOOP

    n = input("You are in the LookupErrorost Forest
    ****************
    ****************
     :)
    ****************
    ****************
     Go left or right? ")
    while n == "right" or n == "Right":
        n = input("You are in the Lost Forest
    ****************
    *********
    (╯°□°)╯︵ ┻━┻
    ****************
    ****************
    Go left or right? ")
    print("
     You got out of the Lost Forest!
    o/")
    
    You are in the LookupErrorost Forest
    ****************
    ****************
     :)
    ****************
    ****************
     Go left or right? right
    You are in the Lost Forest
    ****************
    *********
    (╯°□°)╯︵ ┻━┻
    ****************
    ****************
    Go left or right? left
    
     You got out of the Lost Forest!
    o/
  • 相关阅读:
    纪伯伦:我曾七次鄙视我的灵魂
    字典和集合
    元组
    列表
    字符串
    数值类型
    内置函数了解一下
    了解Python
    centos7安装mysql数据库
    xenserver 上传centos6.8镜像
  • 原文地址:https://www.cnblogs.com/zonghanli/p/13602726.html
Copyright © 2011-2022 走看看