lecture 1 练习

简介: Assume that two variables, varA and varB, are assigned values, either numbers or strings.

Assume that two variables, varA and varB, are assigned values, either numbers or strings.

Write a piece of Python code that prints out one of the following messages:

  • "string involved" if either varA or varB are strings

  • "bigger" if varA is larger than varB

  • "equal" if varA is equal to varB

  • "smaller" if varA is smaller than varB

For problems such as these, do not include raw_input statements or define the variable varA or varB. Our automating testing will provide values of varA and varB for you - so write your code in the following box assuming varA and varB are already defined.

if isinstance(varA, str) or isinstance(varB, str):
	print('string involved')
elif varA > varB:
	print('bigger')
elif varA == varB:
	print('equal')
else:
	print('smaller')

目录
相关文章
|
8月前
|
人工智能 Go
G - MaratonIME does a competition
G - MaratonIME does a competition
|
8月前
|
Java
hdu 1164 Eddy's research I
hdu 1164 Eddy's research I
43 0
|
8月前
|
人工智能 Java
hdu 1165 Eddy's research II
hdu 1165 Eddy's research II
44 0
HDU-1017,A Mathematical Curiosity
HDU-1017,A Mathematical Curiosity
|
机器学习/深度学习 自然语言处理
|
Go 计算机视觉
(转)A Survival Guide to a PhD
Andrej Karpathy blog About Hacker's guide to Neural Networks A Survival Guide to a PhD Sep 7, 2016 This guide is patterned after my “Doing well ...
|
Go 计算机视觉
(转) A Survival Guide to a PhD
  A Survival Guide to a PhD     Sep 7, 2016 This guide is patterned after my “Doing well in your courses”, a post I wrote a long time ago on s...