Skip to content

Commit 1646f29

Browse files
committed
update 2
1 parent 6aacaa6 commit 1646f29

File tree

4 files changed

+520
-8
lines changed

4 files changed

+520
-8
lines changed
+117-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,121 @@
11
{
2-
"cells": [],
3-
"metadata": {},
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"#complex()\n",
8+
"\n",
9+
"complex() returns a complex number with the value real + imag*1j or converts a string or number to a complex number. \n",
10+
"\n",
11+
"If the first parameter is a string, it will be interpreted as a complex number and the function must be called without a second parameter. The second parameter can never be a string. Each argument may be any numeric type (including complex). If imag is omitted, it defaults to zero and the constructor serves as a numeric conversion like int and float. If both arguments are omitted, returns 0j.\n",
12+
"\n",
13+
"If you are doing math or engineering that requires complex numbers (such as dynamics,control systems, or impedence of a circuit) this is a useful tool to have in Python.\n",
14+
"\n",
15+
"Lets see some examples:"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": 2,
21+
"metadata": {
22+
"collapsed": false
23+
},
24+
"outputs": [
25+
{
26+
"data": {
27+
"text/plain": [
28+
"(2+3j)"
29+
]
30+
},
31+
"execution_count": 2,
32+
"metadata": {},
33+
"output_type": "execute_result"
34+
}
35+
],
36+
"source": [
37+
"# Create 2+3j\n",
38+
"complex(2,3)"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": 4,
44+
"metadata": {
45+
"collapsed": false
46+
},
47+
"outputs": [
48+
{
49+
"data": {
50+
"text/plain": [
51+
"(10+1j)"
52+
]
53+
},
54+
"execution_count": 4,
55+
"metadata": {},
56+
"output_type": "execute_result"
57+
}
58+
],
59+
"source": [
60+
"complex(10,1)"
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"metadata": {},
66+
"source": [
67+
"We can also pass strings:"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": 6,
73+
"metadata": {
74+
"collapsed": false
75+
},
76+
"outputs": [
77+
{
78+
"data": {
79+
"text/plain": [
80+
"(12+2j)"
81+
]
82+
},
83+
"execution_count": 6,
84+
"metadata": {},
85+
"output_type": "execute_result"
86+
}
87+
],
88+
"source": [
89+
"complex('12+2j')"
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"Thats really all there is to this useful function. Keep it in mind if you are ever dealing with complex numbers in Python!"
97+
]
98+
}
99+
],
100+
"metadata": {
101+
"kernelspec": {
102+
"display_name": "Python 2",
103+
"language": "python",
104+
"name": "python2"
105+
},
106+
"language_info": {
107+
"codemirror_mode": {
108+
"name": "ipython",
109+
"version": 2
110+
},
111+
"file_extension": ".py",
112+
"mimetype": "text/x-python",
113+
"name": "python",
114+
"nbconvert_exporter": "python",
115+
"pygments_lexer": "ipython2",
116+
"version": "2.7.10"
117+
}
118+
},
4119
"nbformat": 4,
5120
"nbformat_minor": 0
6121
}

0 commit comments

Comments
 (0)