https://en.wikipedia.org/wiki/Processor_register So from the information in this link there are limited Floating point and General Purpose registers in a cpu. My question is how are these registers used. By that I mean let's say I defined some variables in python but I think It's stored in RAM or HDD so does cpu only use those registers when operating on the data fetched from RAM and if so in order to overload cpu's capacity what kind of an algorithm should be followed by such a program ?
As a general rule, variables are never stored on the hard disk (there are exceptions but let's not get into that here). The CPU can perform basic operations (arithmetic, comparisons, bit manipulations) in a number of ways, using registers, cache, stack, or general RAM. Registers are fastest but there aren't many of them.
Whether a programming language uses registers for variables depends a bit on what sort of a language it is. For instance, C is compiled to machine code so that, whenever possible, registers are used. If there aren't enough registers available, the C compiler will use something else (usually the stack). Other languages may use the registers differently. For instance, some languages compile to the so-called bytecode, which is a very simple langauge that is then simulated by the CPU. In such cases a single variable operation may correspond to many CPU operations, and variables would typically not be stored in registers.
In general you do not have to worry how registers will be used. Modern language compilers can figure out register usage really well and in fact are typically better at it than humans. There are of course certain guidelines that will make your code faster, but you should not worry about that. If you are not an experienced programmer, you should first worry about writing decent code, study algorithms, and so on. Optimization at the level of CPU comes later.