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

目录
相关文章
|
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 ...
1014 0
|
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...
1170 0
[Everyday Mathematics]20150306
在王高雄等《常微分方程(第三版)》习题 2.5 第 1 题第 (32) 小题: $$\bex \frac{\rd y}{\rd x}+\frac{1+xy^3}{1+x^3y}=0. \eex$$   解答: $$\beex \bea 0&=(1+xy^3)\rd x+(1+x^3y)\rd y...
641 0
[Everyday Mathematics]20150228
试证: $$\bex \int_0^\infty \sin\sex{x^3+\frac{\pi}{4}}\rd x =\frac{\sqrt{6}+\sqrt{2}}{4}\int_0^\infty e^{-x^3}\rd x. \eex$$
803 0
[Everyday Mathematics]20150220
试求 $$\bex \sum_{k=0}^\infty\frac{1}{(4k+1)(4k+2)(4k+3)(4k+4)}. \eex$$
500 0
[Everyday Mathematics]20150218
设 $A,B$ 是 $n$ 阶复方阵, 适合 $$\bex A^2B+BA^2=2ABA. \eex$$ 试证: 存在 $k\in\bbZ^+$, 使得 $(AB-BA)^k=0$.
469 0
[Everyday Mathematics]20150225
设 $f:\bbR\to\bbR$ 二次可微, 适合 $f(0)=0$. 试证: $$\bex \exists\ \xi\in\sex{-\frac{\pi}{2},\frac{\pi}{2}},\st f''(\xi)=f(\xi)(1+2\tan^2\xi). \eex$$
754 0
[Everyday Mathematics]20150208
对 $f\in C^2(\bbR)$ 适合 $$\bex \vlm{|x|}f(x)=0, \eex$$ 试证: $$\bex \int_{\bbR} |f'|^p\rd x \leq (p-1)^\frac{p}{2}\int_{\bbR} |ff''|^\frac{p}{2} \rd x,\quad p\geq 2.
427 0
[Everyday Mathematics]20150205
设 $\phi:[k_0,\infty)\to[0,\infty)$ 是有界递减函数, 并且 $$\bex \phi(k)\leq \sex{\frac{A}{h-k}}^\al\phi(h)^\beta,\quad k>h\geq k_0, \eex$$ 其中 $A,\al>0$, $\beta>1$.
637 0
[Everyday Mathematics]20150126
设 $A$ 是 $4\times 2$ 阶实矩阵, $B$ 是 $2\times 4$ 阶实矩阵, 满足 $$\bex AB=\sex{\ba{cccc} 1&0&-1&0\\ 0&1&0&-1\\ -1&0&1&0\\ 0&-1&0&1 \ea}. \eex$$ 试求 $BA$.
581 0

热门文章

最新文章