The exercise contains 15 questions. The solution is provided for each question.
Each question contains the necessary skills you need to learn.
I have added tips and required learning resources for each question, which helps you solve the exercise. When you complete each question, you get more familiar with a control structure, loops, string, and list.
Use Online Code Editor to solve exercise questions.
Also, try to solve the basic Python Quiz for beginners
Exercise 1: Given two integer numbers return their product. If the product is greater than 1000, then return their sum
Reference article for help:
Accept user input in Python
Calculate an Average in Python
Given 1:
number1 = 20
number2 = 30
Expected Output:
The result is 600
Given 2:
number1 = 40
number2 = 30
Expected Output:
The result is 70
Explanation:
Maybe Encouragement? I don't know, are there any choices to choose from?
Answer:
206.58.170.67 is the decimal format of the given binary IP address.
Explanation:
we can convert the binary number into decimal by the following procedure.
11001110 = 1x2⁷+1x2⁶+0x2⁵+0x2⁴+1x2³+1x2²+1x2¹+0x2⁰
= 128 + 64 + 0 + 0 + 8 + 4 + 2 + 0
= 206
00111010 = 0x2⁷+0x2⁶+1x2⁵+ 1x2⁴+1x2³+0x2²+1x2¹+0x2⁰
= 0 + 0 + 32 + 16 + 8 + 0 + 2 + 0
= 58
10101010 = 1x2⁷+0x2⁶+1x2⁵+ 0x2⁴+1x2³+0x2²+1x2¹+0x2⁰
= 128 + 0 + 32 + 0 + 8 + 0 + 2 + 0
= 170
01000011 = 0x2⁷+ 1x2⁶+ 0x2⁵+ 0x2⁴+ 0x2³+0x2²+1x2¹+1x2⁰
= 0 + 64 + 0 + 0 + 0 + 0 + 2 + 1
= 67
so, the IP address is becomes 206.58.170.67