<jupyter_start><jupyter_text>All the IPython Notebooks in this **Python Examples** series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/90_Python_Examples)**  Python Program to Parse a String to a Float or IntIn this example, you will learn to parse a string to a float or int.To understand this example, you should have the knowledge of the following **[Python programming](https://github.com/milaan9/01_Python_Introduction/blob/main/000_Intro_to_Python.ipynb)** topics:* **[Python Data Types](https://github.com/milaan9/01_Python_Introduction/blob/main/009_Python_Data_Types.ipynb)*** **[Python Strings](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String.ipynb)**<jupyter_code># Example 1: Parse string into integer

balance_str = "1900"
balance_int = int(balance_str)

# print the type
print(type(balance_int))

# print the value
print(balance_int)

'''
>>Output/Runtime Test Cases:
     
<class 'int'>
1900
'''<jupyter_output><class 'int'>
1900<jupyter_text>**Explanation:** **`int()`** can be used to parse a string to an integer. However, the string must be a numeral value.<jupyter_code># Example 2: Parse string into float

balance_str = "1900.6"
balance_float = float(balance_str)

# print the type
print(type(balance_float))

# print the value
print(balance_float)

'''
>>Output/Runtime Test Cases:
     
<class 'float'>
1900.6
'''<jupyter_output><class 'float'>
1900.6<jupyter_text>**Explanation:** **`float()`**  can be used to parse a string to an integer.<jupyter_code># Example 3: A string float numeral into integer

balance_str = "1900.36"
balance_int = int(float(balance_str))

# print the type
print(type(balance_int))

# print the value
print(balance_int)
    
'''
>>Output/Runtime Test Cases:
     
<class 'int'>
1900
'''<jupyter_output><class 'int'>
1900
{'fraction_non_alphanumeric': 0.13172338090010977, 'fraction_numerical': 0.03567508232711306, 'mean_word_length': 5.802238805970149, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '448869', 'license': 'MIT', 'n_tokens_mistral': 668, 'n_tokens_neox': 602, 'n_words': 172, 'path': '02_Python_Datatypes_examples/018_parse_a_string_to_a_float_or_int.ipynb', 'repo_name': 'peterennis/90_Python_Examples', 'size': '1829'}