Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

Hello World | PROGRAMMING | C - PYTHON 017

Please convert the following C code to Python 

 

#include <stdio.h>

#include<stdlib.h>

int main()
{
int N, X; 

scanf("%d %d", &N, &X); 

for (int ctr = 1; ctr <= X; ctr++) {

N += printf("%d", N); printf(" ");

} return 0;


}

 

SOLUTION :

PYTHON CODE :  

N, X=map(int,input().split()) 

for ctr in range(1,X+1):

    print(N, end=" ")
    t=N
    c=0
    while t!=0:
        t=t//10
        c+=1
    N+=c

 

 



Post a Comment

Previous Post Next Post