JavaPythonTech blog contains various tools and skills for a developer. Java/Python Best Practices, Tools, Examples, Programming interview questions.

Python Programming Questions


  • Print fibonacci  number using recursion.
def fib(x):
   
if x == 0 or x == 1:
       
return x
   
else:
       
return (fib(x-1) + fib(x-2))

for i in range(10):
   
print(fib(i))

  • Print the char and number of occurrences in a given input string.
input = "aaabbccbcc"

map = {}

for c in input:
    if(c in map):
        map[c] += 1
    else:
        map[c]=1print(map)

output = ""

for key,val in map.items():
    st = key+str(val)
    output += stprint(output)

More questions will be added soon!


Share:

No comments:

Post a Comment

Announcements

Will be posting twice a week on latest java libraries/frameworks which a developer needs to know in 2019.
Also will add the common errors and resolutions for the same.

Please feel free to comment if you need anything specific.

Recent Posts

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Contributors

Pages