python学习input函数 - Go语言中文社区

python学习input函数


#函数input
message = input("Tell me something, and I will repeat it back to you: ")
print(message)
message1 = input()
print(message1)


#创建多行字符串的方式
prompt1="type someting"
prompt2=prompt1+": "+input()
print(prompt2)


prompt = "If you tell us who you are, we can personalize the messages you see."
prompt += "nWhat is your first name? "
name = input(prompt)
print("nHello, " + name + "!")


#input默认输入是字符,所以需要字符比较时应当进行类型转换
age=input("How old are you?")
age=int(age)
if(age>=18):
print("You have the right to vote!")
else:
print("Sorry,you have no right to vote!")


#求模运算符
c1=input("Please input a number,and i will do modulo operation for it.")
c1=int(c1)
c2=input("Please input another number,and i will do modulo operation for it.")
c2=int(c2)
c3=c1%c2
print(c3)




#汽车租赁 :编写一个程序,询问用户要租赁什么样的汽车,并打印一条消息,如“Let me see if I can find you a Subaru”。
input("What kind of car would you like to hire?")
print("Let me see if I can find you a Subaru")


#餐馆订位 :编写一个程序,询问用户有多少人用餐。如果超过8人,就打印一条消息,指出没有空桌;否则指出有空桌。
p1=input("How many people in the dinner?")
p1=int(p1)
if(p1>8):
print("Sorry,There is no empty table.")
else:
print("ok,There is an empty table")

#10的整数倍 :让用户输入一个数字,并指出这个数字是否是10的整数倍。
n1=input("Please input a number")
n1=int(n1)
if(n1%10==0):
print(n1+" is an integer multiple of 10.")
else:

print(n1+" is not an integer multiple of 10.")


版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_24135817/article/details/79818479
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-03-07 21:02:51
  • 阅读 ( 902 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢