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

目录
相关文章
|
2月前
|
机器学习/深度学习 自然语言处理 安全
什么是GANs
【10月更文挑战第14天】什么是GANs
|
4月前
|
机器学习/深度学习 PyTorch TensorFlow
GANs
【8月更文挑战第8天】
50 2
|
7月前
|
Java
hdu 1164 Eddy's research I
hdu 1164 Eddy's research I
40 0
|
7月前
|
人工智能 Java
hdu 1165 Eddy's research II
hdu 1165 Eddy's research II
43 0
UVa11565 - Simple Equations
UVa11565 - Simple Equations
54 0
UVa11506 - Angry Programmer(ISAP)
UVa11506 - Angry Programmer(ISAP)
61 0
UVa11714 - Blind Sorting
UVa11714 - Blind Sorting
55 0
UVa389 - Basically Speaking
UVa389 - Basically Speaking
40 0
|
定位技术
German collegiate programming contest 2012 - Ski Jumping
首先用动能定理算出平抛的初速度v0,然后分三种情况,0~L/2,L/2~L,L~无穷远。
139 0
German collegiate programming contest 2012 - Ski Jumping
|
决策智能
BNUOJ 44578 Monty Hall problem
BNUOJ 44578 Monty Hall problem
119 0

热门文章

最新文章