⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 74.html

📁 Python Ebook Python&XML
💻 HTML
字号:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Robots" content="INDEX,NOFOLLOW">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<TITLE>Safari | Python Developer's Handbook -&gt; Miscellaneous</TITLE>
<LINK REL="stylesheet" HREF="oreillyi/oreillyN.css">
</HEAD>
<BODY bgcolor="white" text="black" link="#990000" vlink="#990000" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="100%" cellpadding=5 cellspacing=0 border=0 class="navtopbg"><tr><td><font size="1"><p class="navtitle"><a href="8.html" class="navtitle">Web Development</a> &gt; <a href="0672319942.html" class="navtitle">Python Developer's Handbook</a> &gt; <a href="38.html" class="navtitle">3. Python Libraries</a> &gt; <span class="nonavtitle">Miscellaneous</span></p></font></td><td align="right" valign="top" nowrap><font size="1"><a href="main.asp?list" class="safnavoff">See All Titles</a></font></td></tr></table>
<TABLE width=100% bgcolor=white border=0 cellspacing=0 cellpadding=5><TR><TD>
<TABLE border=0 width="100%" cellspacing=0 cellpadding=0><TR><td align=left width="15%" class="headingsubbarbg"><a href="73.html" title="The String Group"><font size="1">&lt;&nbsp;BACK</font></a></td><td align=center width="70%" class="headingsubbarbg"><font size="1"><a href="popanote.asp?pubui=oreilly&bookname=0672319942&snode=74" target="_blank" title="Make a public or private annnotation">Make Note</a> | <a href="74.html" title="Use a Safari bookmark to remember this section">Bookmark</a></font></td><td align=right width="15%" class="headingsubbarbg"><a href="75.html" title="Generic Operational System"><font size="1">CONTINUE&nbsp;&gt;</font></a></td></TR></TABLE>
<a href="5%2F31%2F2002+4%3A28%3A37+PM.html" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><font color=white size=1>152015024128143245168232148039199167010047123209178152124239215162146114164075115182035241</font><a href="read1.asp?bookname=0672319942&snode=74&now=5%2F31%2F2002+4%3A28%3A37+PM" TABINDEX="-1"><img src=images/spacer.gif border=0 width=1 height=1></a><br>
<FONT><h3>Miscellaneous</h3>
				<p>This group handles many functions that are available for all Python versions.</p>

				<H4><TT Class="monofont">math</TT></H4>
					<P>The <tt clASS="monofont">math</Tt> module provides standard mathematical functions and constants. It doesn't accept complex numbers, only integers and floats. Check out the following example:</p>

					<pre>
						
import math
&gt;&gt;&gt; math.cos(180)
-0.598460069058
&gt;&gt;&gt; math.sin(90)
0.893996663601
&gt;&gt;&gt; math.sqrt(64)
8.0
&gt;&gt;&gt; math.log(10)
2.30258509299
&gt;&gt;&gt; math.pi     # The mathematical constant pi
3.14159265359
&gt;&gt;&gt; math.e      # The mathematical constant e
2.71828182846

					</pre>

				
				<h4><tt class="monofont"><a namE="idx1073742816"></a><a Name="idx1073742817"></A>cmath</tt></h4>
					<p>The <Tt clASS="monofont">cmath</Tt> module also provides standard mathematical functions and constants. However, its implementation enables it to accept complex numbers as arguments. All the returned values are expressed as complex numbers.</p>

				
				<h4><tT CLAss="monofont">random</tt></H4>
					<P>The <TT clasS="monofont">random</TT> module generates pseudo-random numbers. This module implements all the randomizing functions provided by the <Tt class="monofont">whrandom</tt> module plus several pseudo-random real number generators. These random modules aren't very secure for encryption purposes.</p>

					<h5><tt class="monofont">random.choice()</tt></h5>
						<P>It randomly picks one element from <tt ClasS="monofont">list.</tt></p>

						<p><A namE="idx1073742818"></A>basic syntax: <TT clasS="monofont">random.choice(</TT><I><tt clASS="monofont">list</Tt></i><tt CLASs="monofont">)</tt></p>

						<pre>
							
&gt;&gt;&gt; lst = ["A","l","b","a","t","r","o","s","s","!","!"]
&gt;&gt;&gt; while lst:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -