How would I write this line of code in Python? | Sololearn: Learn to code for FREE!

+16

How would I write this line of code in Python?

What would this look like typed out in a text editor, to solve? I already have the answer (1) but want to know how to do this correctly & for the future. 7%(5//2) I tried print 7%(5//2) but it's saying that's incorrect. I also tried print[7%(5//2)] and that came up with an error. Any help would be appreciated. Thanks!!

11/2/2016 11:42:39 PM

Colleen

85 Answers

New Answer

+55

print(7%(5//2))

+17

print(7%(5//2)) Replace "[ ]" brackets with "( )" brackets, following print . First the internal part (5//2) will be executed by geting an output 2(quotient) and then the external part (7%2) will be executed and outputs 1

+13

+10

Print(7%(5//2)) You need parentheses around your main line. And what you want the program to sovle first. So Line 1. Print() Then you want to add 7%(5//2) <—This gose within the above parentheses from line 1. So itll look like Line 1. Print(7%(5//2)) I would like to use brackets to seperate the process but ikd. Im just learning.

+4

To get output of ( 7%(5//2)) First you have to know operator precedence in Python "PEMDAS" is a short form to know when you execute operational statements P - Parenthesis ---> ( ) E - Exponential ---> (**) M - Multiplication ---> * D - Division ---> /(Normal Division) or //(Floor Division) A - Addition ---> + S - Subtraction ---> - ( 7%(5//2) ) 1.First it will execute within parenthesis i.e. 5//2 -> 2 (takes quotient as output) In Python3, 5/2 returns float vale as output => 5/2 = 2.5 5//2 returns integer as output => 5//2 = 2 2. Next it will execute (7%2) Here %(Modulus) will take remainder as output -> 7%2 => 1(remainder) ,3(quotient) 3. Finally it will return 1 as output value (7%(5//2)) -> (7%2) -> 1

+3

for getting answer you need {print() } function for your example : print(7%(5//2)) explaining code: at first it calculate how many 2 come in 5 because of () and // then it calculate The remainder is divided by 7 to 2

+2

print(7%(5//2)) It will count those inside the parenthesis 5//2 which is 2. Then in 7%2 it will divide it and find its remainder which is 1.

+2

simply use BODMAS

+2

print(7%(5//2)) It is like this because you put whatever you want to print in between the brackets.

+2

print(7%(5//2))

+2

[5//2] is a error, because is for lists print(7%(5//2)) Because: Is () because is a expresion matematical

+2

print(7 % (5 // 2))

+2

Fabián Tienes toda la razón.

+1

First use print() to print any result. And ofcourse you must include those round brackets () to print. Now as per your problem it'd be print(7%(5//2))

+1

print (7%(5//2))

+1

print(7%(5//2))

+1

print(7%(5//2))

+1

Print (7%(5//2))

+1

Print(7%(5//2)) 7%5//2 7%(2) 7%2 =3remainder1 Answer=1

+1

Use print (7%(5//2))