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')

目录
相关文章
|
6月前
|
人工智能 Go
G - MaratonIME does a competition
G - MaratonIME does a competition
|
机器学习/深度学习 人工智能 BI
The 15th Chinese Northeast Collegiate Programming Contest
The 15th Chinese Northeast Collegiate Programming Contest
142 0
|
定位技术
German collegiate programming contest 2012 - Ski Jumping
首先用动能定理算出平抛的初速度v0,然后分三种情况,0~L/2,L/2~L,L~无穷远。
135 0
German collegiate programming contest 2012 - Ski Jumping
|
人工智能 BI 容器