title-img


Find Angle MBC Python

Input Format: The first line contains the length of side AB. The second line contains the length of side BC. Constraints: 1. 0<AB<=100 2. 0<BC<=100 3. length AB and BC are natural numbers Output Format: Output angle MBC in degrees.

View Solution →

String Formatting Python

Given an integer, n, print the following values for each integer i from 1 to n: 1. Decimal 2. Octal 3. Hexadecimal (capitalized) 4. Binary The four values must be printed on a single line in the order specified above for each i from 1 to n. Each value should be space-padded to match the width of the binary value of n. Input Format: A single integer denoting n. Constraints: 1<=n<=99 Output Format: Print n lines where each line i (in the range 1<

View Solution →

Mod Divmod Python

One of the built-in functions of Python is divmod, which takes two arguments a and b and returns a tuple containing the quotient of a/b first and then the remainder a. For example: >>> print divmod(177,10) (17, 7) Here, the integer division is 177/10 => 17 and the modulo operator is 177%10 => 7. Task: Read in two integers, a and b, and print three lines. The first line is the integer division a//b (While using Python2 remember to import division from __future__). The second line

View Solution →

Power-Mod Power Python

So far, we have only heard of Python's powers. Now, we will witness them! Powers or exponents in Python can be calculated using the built-in power function. Call the power function a^b as shown below: >>> pow(a,b) or >>> a**b It's also possible to calculate a^b mod m. >>> pow(a,b,m) This is very helpful in computations where you have to print the resultant % mod. Note: Here, a and b can be floats or negatives, but, if a third argument is present, b cannot be negative. Not

View Solution →

Integers Come In All Sizes Python

Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: 2^31-1 (c++ int) or 2^63-1 (C++ long long int). As we know, the result of a^b grows really fast with increasing b. Let's do some calculations on very large integers. Task: Read four numbers, a, b, c, and d, and print the result of a^b+c^d. Input Format: Integers a, b, c, and d are given on four separate lines, respectively. Constraints: 1. 1<=a<=1000 2.

View Solution →