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

目录
相关文章
|
5月前
|
人工智能 Go
G - MaratonIME does a competition
G - MaratonIME does a competition
|
定位技术
German collegiate programming contest 2012 - Ski Jumping
首先用动能定理算出平抛的初速度v0,然后分三种情况,0~L/2,L/2~L,L~无穷远。
134 0
German collegiate programming contest 2012 - Ski Jumping
|
资源调度
(zhuan) Evolution Strategies as a Scalable Alternative to Reinforcement Learning
Evolution Strategies as a Scalable Alternative to Reinforcement Learning this blog from: https://blog.
|
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...
|
资源调度
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.5
Show that the inner product $$\bex \sef{x_1\vee \cdots \vee x_k,y_1\vee \cdots\vee y_k} \eex$$ is equal to the permanent of the $k\times k$ matrix $\sex{\sef{x_i,y_j}}$.
546 0
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.3
Let $\scrM$ be a $p$-dimensional subspace of $\scrH$ and $\scrN$ its orthogonal complement. Choosing $j$ vectors from $\scrM$ and $k-j$ vectors from $...
715 0
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.2
The elementary tensors $x\otimes \cdots \otimes x$, with all factors equal, are all in the subspace $\vee^k\scrH$.
447 0
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.4.5
Suppose it is known that $\scrM$ is an invariant subspace for $A$. What invariant subspaces for $A\otimes A$ can be obtained from this information alone?   Solution.
524 0