+ 8

I want explanation in this code any one help me please

Explanation https://code.sololearn.com/cPiC4E1MJ2m3/?ref=app

6th Sep 2020, 8:44 AM
💓DORAEMON💓😍
33 Respostas
+ 7
fruit = int(input()) def apple(data): data = data//2 # this code line was data = data/2 before solving return data b = apple(fruit) print (b // 3) ---------------------------------------------- fruit=int(input()) converts a string into integer so basically asking a user to enter an integer b=apple(fruit) here apple function is called with fruit as argument for the parameter data and result returned from the apple function is assigned to variable b b//3 is called floor division If b is 7 then you will get 2 as output In function apple , In line data=data//2 ,Data is assigned the result as a evaluation of data//2 and returned back to the function call
6th Sep 2020, 8:55 AM
Abhay
Abhay - avatar
+ 7
Md. Nasif-ur-Rahman Rimon thank you a lot ,thank you so much now i am clear
6th Sep 2020, 9:24 AM
💓DORAEMON💓😍
+ 3
Md. Nasif-ur-Rahman Rimon yeah and thank you for explaining me how to mention in comments
6th Sep 2020, 9:10 AM
💓DORAEMON💓😍
+ 3
The code is very simple and straightforward first it takes input from the user the change it into integer (because it is string by default) and then pass it into a function named apple which gives the remainder of input when divided from 2 and then it stores the value in b variable the. It prints the remained of b with 3 Read this comment while reading the code at the same time you will easily get what I am saying in 2-3 times 🙂🙂
6th Sep 2020, 8:13 PM
Adarsh chaurasia
Adarsh chaurasia - avatar
7th Sep 2020, 6:55 AM
💓DORAEMON💓😍
+ 3
This code was just about dividing the total number of fruits by 2 to have the half(number of apples) and now dividing the number of apples by 4 to know how many pies you can do.it is simple arithmetic
7th Sep 2020, 11:01 AM
tsdareen
tsdareen - avatar
+ 2
#First, fruit=int(input()) #You called function def apple(data): #Second data=data//2 return data #Recall b=apple(fruit) print(b//3) #fruit=29 data=29//2=14 return data #returns 14 b=apple(data) #b=14 print(b//3) #4
6th Sep 2020, 8:54 AM
Web-Learner
+ 2
Md. Nasif-ur-Rahman Rimon actually how we are able to know that we have to take 6 there
6th Sep 2020, 8:55 AM
💓DORAEMON💓😍
+ 2
Yeah
6th Sep 2020, 8:58 AM
💓DORAEMON💓😍
+ 2
i did not undersrood and please tell me how to mention u in comments
6th Sep 2020, 9:02 AM
💓DORAEMON💓😍
+ 2
Abhay hello here in this code first they took apple function with argument as data and again they took fruit as argument i did not understand there and how we are able to know that we have to take 2 and 3 in floor division
6th Sep 2020, 9:16 AM
💓DORAEMON💓😍
+ 2
Md.Nasif-ur-Rahaman Rimon here the test cases are not solved it is showing incorrect answers
6th Sep 2020, 9:32 AM
💓DORAEMON💓😍
+ 2
6th Sep 2020, 9:36 AM
💓DORAEMON💓😍
+ 2
Md. Nasif-ur-Rahman Rimon i got it but i have a doubt why we used floor division why cant we use% ?
6th Sep 2020, 10:03 AM
💓DORAEMON💓😍
6th Sep 2020, 10:19 AM
💓DORAEMON💓😍
+ 2
Md. Nasif-ur-Rahman Rimon do u know how to do gotham city task in c 😊
7th Sep 2020, 6:58 AM
💓DORAEMON💓😍
+ 1
Md. Nasif-ur-Rahman Rimon how we are able to know that we have to use only floor division
6th Sep 2020, 4:10 PM
💓DORAEMON💓😍
+ 1
Md. Nasif-ur-Rahman Rimon i am getting error in c
7th Sep 2020, 7:01 AM
💓DORAEMON💓😍
+ 1
Md. Nasif-ur-Rahman Rimon pls shate ur code pls i did npt save it
7th Sep 2020, 8:36 AM
💓DORAEMON💓😍
+ 1
Md. Nasif-ur-Rahman Rimon Sorry bro i am not bro i am sister please tell me how to share it bcoz i dont know and iam a beginner 😅
7th Sep 2020, 8:51 AM
💓DORAEMON💓😍