Python Interview Question asked in Amazon for Business Research Analyst

preview_player
Показать описание
If you want to learn Data Science from scratch and crack interviews, join our Assignment based Data Science course for complete Hands on Practical Learning Experience with 1-1 Live Mentorship support on Skype chat everyday for doubt clearance.

Duration: 3-4 Months in general (This is a Self-Paced course with lifetime access, you can learn according to your time availability and from anywhere.)

In the Combo Course we have covered

1. Python for Data Science: 998/-

2. Machine Learning for Data Science: 1499/-

3. Maths and Stats for Data Science: 999/-

4. SQL for Data Science: 1199/-

5. Deep Learning for Data Science: 2999/-

6. ML Capstone Projects: 799/-

7. DL Capstone Projects: 899/-

8. Company wise Interview QnA: 499/-

9. AWS Sagemaker Course: 498/-

Actual price is 10389 but it is available at 3999/- today

Рекомендации по теме
Комментарии
Автор

def min_step(num):
count = 0
while(num!=0):
if(num%2==0):
num = num//2
count = count + 1
else:
num = num - 1
count = count + 1
return count

print(min_step(12))

O/p = 5

SumitKumar-vxfe
Автор

# steps required to reduce a number to 0

inp= int(input("Enter the number: "))
steps=0
val= inp
while (val!=0):
if (val % 2 !=0):
val = val - 1
val = val / 2
steps = steps + 1
elif( val %2 ==0):
val = val / 2
steps = steps + 1
if val <= 0 :
break
print(val, steps)

hariprasath
Автор

number = 1
number1 = number -1
print(number 1)

As simple as that

sayantanganguly
Автор

you are starting the range with 0, so the step size is going to be always -1 the actual step size taken.

hariprasath
Автор

n=int(input())
for i in range(n):
if n%2==0:
n=n/2
elif n%2==1:
n=n-1

if n<=0:
break
print(i)
bro, i got this as output (i=4) it is the lowest reduced value, i got . it is right or wrong tell me

prajwalgs