FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learn-python3/samples/function/def_func.py at master · sofay/learn-python3 · GitHub
sofay
/
learn-python3
Public
forked from
michaelliao/learn-python3
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
learn-python3
/
samples
/
function
/
def_func.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
26 lines (20 loc) · 466 Bytes
Breadcrumbs
learn-python3
/
samples
/
function
/
def_func.py
Copy path
File metadata and controls
executable file
·
26 lines (20 loc) · 466 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import
math
def
my_abs
(
x
):
if
not
isinstance
(
x
, (
int
,
float
)):
raise
TypeError
(
'bad operand type'
)
if
x
>=
0
:
return
x
else
:
return
-
x
def
move
(
x
,
y
,
step
,
angle
=
0
):
nx
=
x
+
step
*
math
.
cos
(
angle
)
ny
=
y
-
step
*
math
.
sin
(
angle
)
return
nx
,
ny
n
=
my_abs
(
-
20
)
print
(
n
)
x
,
y
=
move
(
100
,
100
,
60
,
math
.
pi
/
6
)
print
(
x
,
y
)
# TypeError: bad operand type:
my_abs
(
'123'
)
Back
|
FazBrowse Home
|
New Git URL