FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python_Tutorials/Python_Informatics/3_parse_float.py at master · morad1998/Python_Tutorials · GitHub
morad1998
/
Python_Tutorials
Public
forked from
mGalarnyk/Python_Tutorials
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Python_Tutorials
/
Python_Informatics
/
3_parse_float.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (20 loc) · 677 Bytes
Breadcrumbs
Python_Tutorials
/
Python_Informatics
/
3_parse_float.py
Copy path
File metadata and controls
25 lines (20 loc) · 677 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
# -*- coding: utf-8 -*-
"""
Michael Galarnyk
Given the following python statement…
avg_str = 'Average value read: 0.72903'
Use the find() method and string slicing
to extract the potion of the string after
the colon character and then use the float()
function to convert the extracted string
into a floating point value. Save your code
in a file named “parse_float.py”.
"""
avg_str
=
'Average value read: 0.72903'
start_pos
=
avg_str
.
find
(
':'
);
# 1 more since start_po is after :
start_pos
=
start_pos
+
1
;
# taking the number portion of the string
number_portion
=
avg_str
[
start_pos
:];
# typecasting number_portion to float
number_portion
=
float
(
number_portion
)
Back
|
FazBrowse Home
|
New Git URL