fork download
  1. # your code goes here
  2. """ base58 encoding / decoding functions """
  3. import unittest
  4.  
  5. alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
  6. base_count = len(alphabet)
  7.  
  8. def encode(num):
  9. """ Returns num in a base58-encoded string """
  10. encode = ''
  11.  
  12. if (num < 0):
  13. return ''
  14.  
  15. while (num >= base_count):
  16. mod = num % base_count
  17. encode = alphabet[mod] + encode
  18. num = num / base_count
  19.  
  20. if (num):
  21. encode = alphabet[num] + encode
  22.  
  23. return encode
  24.  
  25. def decode(s):
  26. """ Decodes the base58-encoded string s into an integer """
  27. decoded = 0
  28. multi = 1
  29. s = s[::-1]
  30. for char in s:
  31. decoded += multi * alphabet.index(char)
  32. multi = multi * base_count
  33.  
  34. return decoded
  35.  
  36. class Base58Tests(unittest.TestCase):
  37.  
  38. def test_alphabet_length(self):
  39. self.assertEqual(58, len(alphabet))
  40.  
  41. def test_encode_10002343_returns_Tgmc(self):
  42. result = encode(10002343)
  43. self.assertEqual('Tgmc', result)
  44.  
  45. def test_decode_Tgmc_returns_10002343(self):
  46. decoded = decode('Tgmc')
  47. self.assertEqual(10002343, decoded)
  48.  
  49. def test_encode_1000_returns_if(self):
  50. result = encode(1000)
  51. self.assertEqual('if', result)
  52.  
  53. def test_decode_if_returns_1000(self):
  54. decoded = decode('if')
  55. self.assertEqual(1000, decoded)
  56.  
  57. def test_encode_zero_returns_empty_string(self):
  58. self.assertEqual('', encode(0))
  59.  
  60. def test_encode_negative_number_returns_empty_string(self):
  61. self.assertEqual('', encode(-100))
  62.  
  63. if __name__ == '__main__':
  64. #print encode(int("00B94BA6C51B3D8372D82FDE5DC78773D960B5A82FCDAC8181",16))
  65. print hex(decode("Wh4bh"))
Success #stdin #stdout 0.03s 8036KB
stdin
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.
stdout
0x1406e058