Done - Programming - Nairaland
Nairaland Forum / Science/Technology / Programming / Done (897 Views)
Books On Python / What Can Python Programming Language Build? / Python Programming (2) (3) (4)
(1) (Reply) (Go Down)
Done by Nobody: 11:27am On Nov 07, 2013 |
... |
Re: Done by Sundayademola(m): 1:31pm On Nov 07, 2013 |
Nice set of questions you have there, will love to see you try out some of them before asking for help when stuck. Nice day & look forward to helping you. |
Re: Done by Nobody: 1:40pm On Nov 07, 2013 |
... |
Re: Done by Sundayademola(m): 3:08pm On Nov 07, 2013 |
Nice one then, will check them out. Nice day |
Re: Done by Nobody: 5:04pm On Nov 07, 2013 |
.... |
Re: Done by codeaddict(m): 5:37pm On Nov 07, 2013 |
Something that works: Replace ![wink](https://www.nairaland.com/faces/wink.png) with ) ''' Created on Nov 7, 2013
@author: _where ''' def ex4(x,y): colWid = str(len(str(x ** y))) # column width for i in range(x): for p in range (y): print('%s' % ('%' + colWid + 's') % (i+1)**(p+1), end=' ') print('\n') def ex5(x): for k in [x for x in x.split(' ') if x != '']: print(k)
def ex6(x): a = [0,0,0,0,0] # store number of occurrence of each vowel b = ['a', 'e', 'i', 'o', 'u'] for c in x: if (c == 'a' or c == 'A'): a[0] += 1 elif (c == 'e' or c == 'E'): a[1] += 1 elif (c == 'i' or c == 'I'): a[2] += 1 elif (c == 'o' or c == 'O'): a[3] += 1 elif (c == 'u' or c == 'U'): a[4] += 1 else: pass if (max(a) == 0): print("No vowels in text"![wink](https://www.nairaland.com/faces/wink.png) else: e = [d for d in range(5) if a[d] == max(a)] for f in e: print(b[f], '-->', a[f]) def ex7(x, key): z = ' ' for a in x: if a == ' ': z += a else: z += chr(((ord(a) - 97 + key) % 26) +97) print("Encrypted/Decrypted value --> ", z)
def ex8(x): lst = [] # check if input is a valid expression for the reverse polish notation for a in x: if ((a.isdigit()) or (a == '+') or (a == '*') or (a == '-') or (a == ' ')): pass else: print("Invalid character in string --> ", a); return for a in x: if (a.isdigit()): lst.append(a) elif (a == '+' or a == '*' or a == '-'): if len(lst) >= 2: t = int(lst.pop()) lst.append((eval('int(lst.pop()) %s t' % a))) else: print("Invalid input. Length of stack should be greater than or equal two"![wink](https://www.nairaland.com/faces/wink.png) return else: print("Invalid character in string --> ", a) if len(lst) == 1: print(lst[0]) else: print("Invalid input. Final length of stack should be one"![wink](https://www.nairaland.com/faces/wink.png)
# Used to test the functions. """ if __name__ == '__main__': print ("Exercise Four: "![wink](https://www.nairaland.com/faces/wink.png) x = (int)(input("How many rows do you want?" ) y = (int)(input("How many columns do you want?" ) ex4(x,y) print("\n\nExercise Five: "![wink](https://www.nairaland.com/faces/wink.png) ex5(input("Enter line of text >>> " ) print("\n\nExercise Six: "![wink](https://www.nairaland.com/faces/wink.png) ex6(input("Enter line of text >>> " ) print("\n\nExercise Seven: "![wink](https://www.nairaland.com/faces/wink.png) x = input("Enter string to encrypt/decrypt >>> "![wink](https://www.nairaland.com/faces/wink.png) key = (int)(input("Enter Key >> " ) ex7(x,key) print("\n\nExercise Eight: "![wink](https://www.nairaland.com/faces/wink.png) ex8(input("Enter string >>> " ) """
|
Re: Done by Nobody: 9:20pm On Nov 08, 2013 |
... |
Re: Done by codeaddict(m): 8:02am On Nov 09, 2013 |
boykelex: Thank you very much boss....can I have your facebook or twitter username Once again Big Thanks for the Help PM |