At this study session, I was going to do some programming using Python.
The following 4 questions were challenged in this lecture
9×9 curtain Odds of Oddness Is. Below, I will describe the points that I personally felt different from java and C language when I actually solved these problems.
9×9
In this problem, I mainly solved the problem by dealing with numerical values in the input function.
Python is different from the java and C languages you've learned so far
a = 1
I thought that it is a very convenient point that the output becomes 1
just by inputting
Also, use map (int, input (). Split ())
when entering multiple numbers in one line.
curtain
In this problem, if the difference between A and 2B is less than 0, the window will be completely covered.
ʻIf [conditional expression]:
[Processing when the conditional expression is true]
else:
[Processing when the condition is false] `
It was easy to solve using.
The difference between the If statement and java or C language is that after entering the conditional expression,: is required, and when entering the processing content, enter it with a line break.
Odds of Oddness
In this problem, if the number of N entered is even, the odd numbers below N will be N / 2, and if N is odd, the odd numbers below N will be N / 2 + 1. It can be solved by using the if statement used. Here we use a new remainder and division.
The remainder of x ÷ y is in x% y
You can find the quotient of x ÷ y with x / y
In this problem, I solved the problem by dividing it into even numbers when the remainder was 0 and odd numbers when it was not 0.
Recommended Posts