Posts

Showing posts with the label basic coding interview programs

Alphabet patterns in python

problem 1: sample input:5 sample output: A B C D E F G H I J K L M N O python code: import string x=string.ascii_uppercase k=0 n=int(input()) for i in range(n):     for j in range(i+1):         print(x[k],end=' ')         k+=1     print('\r')    problem 2: sample input:5 sample output: a b c d e f g h i j k l m n o python code: import string x=string.ascii_lowercase k=0 n=int(input()) for i in range(n):     for j in range(i+1):         print(x[k],end=' ')         k+=1     print('\r') problem 3: sample input:5 sample output: A B B C C C D D D D E E E E E python code: import string x=string.ascii_uppercase k=0 n=int(input()) for i in range(n):     for j in range(i+1):         print(x[k],end=' ')     k+=1     print('\r')      problem ...

whether a word is palindrome or not using functions

As we all know,python is an easy  to start programming language. coding programs are the most problems given in hiring interviews. So,lets get started basic programs. problem: Find out whether a given word is palindrome or not. sample input: madam sample output: palindrome python code: def palin(word):     if len(word)<2:         return True     if word[0]==word[-1]:         return palin(word[1:-1])     else:         return False n=input() result=palin(n) if(result):     print('palindrome') else:     print('not palindrome')