# your code goes here """ base58 encoding / decoding functions """ import unittest alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' base_count = len(alphabet) def encode(num): """ Returns num in a base58-encoded string """ encode = '' if (num < 0): return '' while (num >= base_count): mod = num % base_count encode = alphabet[mod] + encode num = num / base_count if (num): encode = alphabet[num] + encode return encode def decode(s): """ Decodes the base58-encoded string s into an integer """ decoded = 0 multi = 1 s = s[::-1] for char in s: decoded += multi * alphabet.index(char) multi = multi * base_count return decoded class Base58Tests(unittest.TestCase): def test_alphabet_length(self): self.assertEqual(58, len(alphabet)) def test_encode_10002343_returns_Tgmc(self): result = encode(10002343) self.assertEqual('Tgmc', result) def test_decode_Tgmc_returns_10002343(self): decoded = decode('Tgmc') self.assertEqual(10002343, decoded) def test_encode_1000_returns_if(self): result = encode(1000) self.assertEqual('if', result) def test_decode_if_returns_1000(self): decoded = decode('if') self.assertEqual(1000, decoded) def test_encode_zero_returns_empty_string(self): self.assertEqual('', encode(0)) def test_encode_negative_number_returns_empty_string(self): self.assertEqual('', encode(-100)) if __name__ == '__main__': #print encode(int("00B94BA6C51B3D8372D82FDE5DC78773D960B5A82FCDAC8181",16)) print hex(decode("Wh4bh"))
Here's a compilation of key Class 11 CBSE Physics formulas, along with the contexts in which they are used, the meaning of symbols, and deep explanations of each formula. --- ### 1. **Kinematics** #### (a) **First Equation of Motion**: **Formula**: \[ v = u + at \] - **Where to use**: For linear motion with constant acceleration to find final velocity. - **Symbols**: - \( v \): Final velocity (m/s) - \( u \): Initial velocity (m/s) - \( a \): Acceleration (m/s²) - \( t \): Time (s) #### (b) **Second Equation of Motion**: **Formula**: \[ s = ut + \frac{1}{2} a t^2 \] - **Where to use**: To find displacement during uniformly accelerated motion. - **Symbols**: - \( s \): Displacement (m) - \( u \): Initial velocity (m/s) - \( a \): Acceleration (m/s²) - \( t \): Time (s) #### (c) **Third Equation of Motion**: **Formula**: \[ v^2 = u^2 + 2as \] - **Where to use**: To find the final velocity when time is unknown. - **Symbols**: - \( v \): Final velocity (m/s) - \( u \): Initial velocity (m/s) - \( a \): Acceleration (m/s²) - \( s \): Displacement (m) --- ### 2. **Newton’s Laws of Motion** #### (a) **Newton's Second Law**: **Formula**: \[ F = ma \] - **Where to use**: To calculate force when mass and acceleration are known. - **Symbols**: - \( F \): Force (N or kg·m/s²) - \( m \): Mass (kg) - \( a \): Acceleration (m/s²) --- ### 3. **Work, Energy, and Power** #### (a) **Work Done by a Force**: **Formula**: \[ W = F \cdot d \cdot \cos \theta \] - **Where to use**: To calculate work when a force is applied at an angle. - **Symbols**: - \( W \): Work (J or N·m) - \( F \): Force (N) - \( d \): Displacement (m) - \( \theta \): Angle between force and displacement #### (b) **Kinetic Energy**: **Formula**: \[ KE = \frac{1}{2} mv^2 \] - **Where to use**: To calculate the energy of a moving object. - **Symbols**: - \( KE \): Kinetic energy (J) - \( m \): Mass (kg) - \( v \): Velocity (m/s) #### (c) **Potential Energy (Gravitational)**: **Formula**: \[ PE = mgh \] - **Where to use**: To calculate the energy of an object at height \( h \) above the ground. - **Symbols**: - \( PE \): Potential energy (J) - \( m \): Mass (kg) - \( g \): Gravitational acceleration (9.8 m/s²) - \( h \): Height (m) #### (d) **Power**: **Formula**: \[ P = \frac{W}{t} \] - **Where to use**: To calculate power when work and time are known. - **Symbols**: - \( P \): Power (W or J/s) - \( W \): Work (J) - \( t \): Time (s) --- ### 4. **Gravitation** #### (a) **Newton's Law of Universal Gravitation**: **Formula**: \[ F = \frac{G m_1 m_2}{r^2} \] - **Where to use**: To calculate the gravitational force between two masses. - **Symbols**: - \( F \): Gravitational force (N) - \( G \): Universal Gravitational constant (\( 6.67 \times 10^{-11} \, \text{N} \cdot \text{m}^2/\text{kg}^2 \)) - \( m_1, m_2 \): Masses (kg) - \( r \): Distance between masses (m) #### (b) **Gravitational Potential Energy**: **Formula**: \[ U = - \frac{G M m}{r} \] - **Where to use**: To calculate potential energy in a gravitational field. - **Symbols**: - \( U \): Potential energy (J) - \( G \): Gravitational constant - \( M \): Mass of large object (e.g., Earth) (kg) - \( m \): Mass of small object (kg) - \( r \): Distance between objects (m) --- ### 5. **Rotational Motion** #### (a) **Torque**: **Formula**: \[ \tau = rF \sin \theta \] - **Where to use**: To calculate the turning effect of a force. - **Symbols**: - \( \tau \): Torque (N·m) - \( r \): Radius or distance from axis of rotation (m) - \( F \): Force (N) - \( \theta \): Angle between force and radius #### (b) **Moment of Inertia (Rotational Inertia)**: **Formula**: \[ I = \sum m r^2 \] - **Where to use**: To calculate rotational inertia for different bodies. - **Symbols**: - \( I \): Moment of inertia (kg·m²) - \( m \): Mass (kg) - \( r \): Distance from axis of rotation (m) #### (c) **Angular Momentum**: **Formula**: \[ L = I \omega \] - **Where to use**: To calculate angular momentum. - **Symbols**: - \( L \): Angular momentum (kg·m²/s) - \( I \): Moment of inertia (kg·m²) - \( \omega \): Angular velocity (rad/s) --- ### 6. **Thermodynamics** #### (a) **First Law of Thermodynamics**: **Formula**: \[ \Delta U = Q - W \] - **Where to use**: To relate heat, work, and internal energy changes in a thermodynamic process. - **Symbols**: - \( \Delta U \): Change in internal energy (J) - \( Q \): Heat added to the system (J) - \( W \): Work done by the system (J) --- ### 7. **Waves and Oscillations** #### (a) **Wave Speed**: **Formula**: \[ v = f \lambda \] - **Where to use**: To calculate the speed of a wave. - **Symbols**: - \( v \): Wave speed (m/s) - \( f \): Frequency (Hz) - \( \lambda \): Wavelength (m) #### (b) **Simple Harmonic Motion (SHM)**: **Formula for displacement**: \[ x(t) = A \cos (\omega t + \phi) \] - **Where to use**: For displacement in simple harmonic motion. - **Symbols**: - \( x(t) \): Displacement at time \( t \) (m) - \( A \): Amplitude (maximum displacement) (m) - \( \omega \): Angular frequency (rad/s) - \( t \): Time (s) - \( \phi \): Phase constant (rad) #### (c) **Time Period of a Pendulum**: **Formula**: \[ T = 2\pi \sqrt{\frac{l}{g}} \] - **Where to use**: To calculate the time period of a simple pendulum. - **Symbols**: - \( T \): Time period (s) - \( l \): Length of the pendulum (m) - \( g \): Gravitational acceleration (m/s²) --- These formulas cover the fundamental concepts in Class 11 Physics. Understanding where and how to apply them is key to solving problems effectively.