Quick and dirty:
bpy.context.scene['MyProperty'] = 5 # or 'yay' or whatever
You do not have to declare anything when using this method.But this is adding to the struct "scene", more practical:
bpy.types.Scene.MyProperty = 5 # registers a new variable to the scene
print(bpy.context.scene.MyProperty) # prints 5
Cleanest way I know of:
bpy.types.Scene.MyProperty = bpy.props.FloatProperty()
If you want to use it as part of an addon, you may want to check if MyProperty registered already, otherwise you risk overwriting settings from the previous session.
More information: https://docs.blender.org/api/current/bpy.props.html
To display your value, you can use any field with information, e.g.
def draw(self, context):
self.layout.label(text=str(bpy.context.scene.MyProperty))
More info about panels here: https://docs.blender.org/api/current/bpy.types.Panel.html