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 ...
1023 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...
1174 0
[Everyday Mathematics]20150305
设 $f\in C^2[0,1]$, $$\bex f(0)=-1,\quad f'(1)=3,\quad \int_0^1 xf''(x)\rd x=1. \eex$$ 试求 $f(1)$.   解答: $$\beex \bea 1&=\int_0^1 x\rd f'(x)\\ &=xf'(x...
676 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$$
813 0
[Everyday Mathematics]20150220
试求 $$\bex \sum_{k=0}^\infty\frac{1}{(4k+1)(4k+2)(4k+3)(4k+4)}. \eex$$
500 0
[Everyday Mathematics]20150221
设 $y_n=x_n^2$ 如下归纳定义: $$\bex x_1=\sqrt{5},\quad x_{n+1}=x_n^2-2\ (n=1,2,\cdots). \eex$$ 试求 $\dps{\vlm{n}\frac{x_1x_2\cdots x_n}{x_{n+1}}}$.
566 0
[Everyday Mathematics]20150226
设 $z\in\bbC$ 适合 $|z+1|>2$. 试证: $$\bex |z^3+1|>1. \eex$$
633 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.
429 0
[Everyday Mathematics]20150210
设正方体 $ABCD-A_1B_1C_1D_1$ 的棱长为 $1$, $E$ 为 $AB$ 的中点, $P$ 为体对角线 $BD_1$ 上一点, 当 $\angle CPE$ 最大时, 求三菱锥 $P-BCE$ 的体积.
647 0

热门文章

最新文章