【坚持】Selenium+Python学习之从读懂代码开始 DAY2
2018/05/10
[来源:菜鸟教程](http://www.runoob.com/python3/python3-examples.html)
#No.1
# 二次方程式 ax**2 + bx + c = 0
# a、b、c 用户提供
# 导入 cmath(复杂数学运算) 模块
'''
cmath.sqrt(x)
Return the square root of x.
'''
import cmath
a = float(input('please input a:'))
b = float(input('please input b:'))
c = float(input('please input c:'))
d = (b**2) - (4*a*c)
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
print('result is {0} and {1}'.format(sol1,sol2))
result:
d:\fly\HTML
λ python test.py
please input a:4
please input b:5
please input c:6
result is (-0.625-1.0532687216470449j) and (-0.625+1.0532687216470449j)
#No.2
'''
random.randint(a, b)
Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).
'''
import random
print(random.randint(0 , 9))
print(random.randrange(0 , 9))
result:
d:\fly\HTML
λ python test.py
0
3
#No.3
num = float(input('please input a num:'))
if num > 0:
print('positive number')
elif num == 0:
print('zero')
else:
print('negative number')
or
num = float(input('please input a num:'))
if num >=0:
if num == 0:
print('zero')
else:
print('positive number')
else:
print('negative number')
result:
d:\fly\HTML
λ python test.py
please input a num:8
positive number
d:\fly\HTML
λ python test.py
please input a num:0
zero
d:\fly\HTML
λ python test.py
please input a num:-9
negative number
【坚持】Selenium+Python学习之从读懂代码开始 DAY2的更多相关文章
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY1
学习Selenium+Python已经好几个月了,但越学发现不懂的东西越多. 感觉最大的问题还是在于基础不扎实,决定从头开始,每天坚持读代码,写代码. 相信量变一定能到质变!!! 2018/05/09 ...
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY7
2018/05/25 EC [EC](https://github.com/easonhan007/webdriver_guide/blob/master/34/expected_conditions ...
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY6
2018/05/23 Python内置的@property装饰器 [@property](https://www.programiz.com/python-programming/property) ...
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY5
2018/05/22 函数作为返回值 [来源:廖雪峰的官方网站](https://www.liaoxuefeng.com/) #No.1 def lazy_sum(*args): def sum(): ...
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY3
2018/05/15 [来源:菜鸟教程](http://www.runoob.com/python3/python3-examples.html) #No.1 list = [1, 2, 3, 4] ...
- 【坚持】Selenium+Python学习之从读懂代码开始 DAY4
2018/05/21 [生成器详解:廖雪峰的官方网站](https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d ...
- 软件测试自动化…python学习到什么程度?代码好不好学!
软件测试自动化…python学习到什么程度?代码好不好学! 如下:
- Gradle学习系列之三——读懂Gradle语法
在本系列的上篇文章中,我们讲到了创建Task的多种方法,在本篇文章中,我们将学习如何读懂Gradle. 请通过以下方式下载本系列文章的Github示例代码: git clone https://git ...
- selenium+python学习总结
学习了一个月的selenium+python,终于学有所成,下面以一个简单的项目来总结学习所得. 1. 项目结构 在项目结构中,大家要注意到:每一个源文件夹中都要有一个__init__ ...
随机推荐
- xmppframework 简介
XMPPFramework是一个OS X/iOS平台的开源项目,使用Objective-C实现了XMPP协议(RFC-3920),同时还提供了用于读写XML的工具,大大简化了基于XMPP的通信应用的开 ...
- Android开发之自己定义TabHost文字及背景(源码分享)
使用TabHost 能够在一个屏幕间进行不同版面的切换,而系统自带的tabhost界面较为朴素,我们应该怎样进行自己定义改动优化呢 MainActivity的源码 package com.dream. ...
- Java导包后在测试类中执行正确但在Servlet中执行错误报ClassNotFoundException或者ClassDefNotFoundException解决办法
将原来导的包remove from build path,并复制到Web-root下的lib目录中,再add to build path,
- XML的序列化用法 vs平台开发
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { NewMethod(); } } #region 读取 ...
- #leetcode刷题之路22-括号生成
给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合. 例如,给出 n = 3,生成结果为:[ "((()))", "(()())&q ...
- swiper插件几个容易忽略的地方
以下内容为swiper4版本的 1.在我们用swiper插件做轮播的当我们左右滑动后会出现自动轮播停止了 此时我们需要在autoplay中 加上这个属性 autoplay:{ delay:1000, ...
- 可编辑div中包含子元素时获取光标位置不准确的问题
前言: 高亮显示输入框中的关键字符,这就必须得用到可编辑div(或其他标签)元素了,这时我们需要获取光标的位置,以便插入字符. 正文: 正常情况下获取光标位置,代码如下: function getPo ...
- linux环境mysql的安装主从关系的配置
- mysql secure_file_priv 文件读写问题
secure_file_priv特性 使用 show global variables like '%secure%'; 查询显示 secure_file_priv的值为null,那么secure_f ...
- IP组播 MulticastChannel接口 DatagramChannel实现
监听者 import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; impo ...