Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,209,228 members, 8,005,316 topics. Date: Sunday, 17 November 2024 at 08:39 PM

Done - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Done (880 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 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
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
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

# Used to test the functions.
"""
if __name__ == '__main__':
print ("Exercise Four: "wink
x = (int)(input("How many rows do you want?"wink)
y = (int)(input("How many columns do you want?"wink)
ex4(x,y)

print("\n\nExercise Five: "wink
ex5(input("Enter line of text >>> "wink)

print("\n\nExercise Six: "wink
ex6(input("Enter line of text >>> "wink)

print("\n\nExercise Seven: "wink
x = input("Enter string to encrypt/decrypt >>> "wink
key = (int)(input("Enter Key >> "wink)
ex7(x,key)

print("\n\nExercise Eight: "wink
ex8(input("Enter string >>> "wink)
"""
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

(1) (Reply)

C++/c Compilers Are So Bad. / 10 Ways To Keep Your Computer/Laptop/Mobile Phone Malware-free / Cti Software Engineering Scholarship

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.