Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.66 KB | None | 0 0
  1. import random
  2. print("List of possible functions:\nPrintTo()\nLineChars()\nBackwardsStr()\nCase()\nQuestion()\nEmailCheck()\nStrLen()\nBackwardsSentence()\nCapitalise()\nRandNumMatrix()\nPatternPrint()\nVowels()\nTeacherCodes()\n")
  3.  
  4. StrNum = 0
  5. StrNum2 = 0
  6. FinalChoice = ("")
  7. Running = True
  8. Alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","!","£","$","%","&","*","(",")","€","¬",":",";","@","#","[","]","{","}"]
  9.  
  10. def Reset():
  11.     StrNum = 0
  12.     StrNum2 = 0
  13.     FinalChoice = ("")
  14.     Running = True
  15.     Alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","!","£","$","%","&","*","(",")","€","¬",":",";","@","#","[","]","{","}"]
  16.  
  17. def PrintTo():
  18.     global StrNum,StrNum2
  19.     Reset()
  20.     FirstChoice = input("Enter Words here\n")
  21.     StrNum = int(input("Enter number of letters to print\n"))
  22.     StrNum2 = int(input("Enter number of letter to start at(0 begins at beginning)\n"))
  23.     for i in range (StrNum2,(StrNum2+StrNum)):
  24.         FinalChoice = FinalChoice + FirstChoice[i]
  25.     return FinalChoice
  26.  
  27.  
  28. def LineChars():
  29.     global StrNum
  30.     Reset()
  31.     FirstChoice = input("Enter Words here\n")
  32.     for i in FirstChoice:
  33.         print(FirstChoice[StrNum])
  34.         StrNum = StrNum + 1
  35.  
  36.  
  37. def BackwardsStr():
  38.     Reset()
  39.     FirstChoice = input("Enter Words here\n")
  40.     StrNum = (int(len(FirstChoice)))
  41.     for i in range(0,StrNum):
  42.         StrNum2 = StrNum - i - 1
  43.         FinalString = FinalString + FirstChoice[StrNum2]
  44.     return print(FinalString)
  45.  
  46.    
  47. def Case():
  48.     Reset()
  49.     FirstChoice = input("Enter Words here\n")
  50.     SecondChoice = input("Do you want upper case or lower case? Type 'Upper' or 'Lower'\n")
  51.     if SecondChoice == ("Upper"):
  52.         FirstChoice = FirstChoice.upper()
  53.     elif SecondChoice == ("Lower"):
  54.         FirstChoice = FirstChoice.lower()
  55.     else:
  56.         print("Can't do that! Check your spelling")
  57.         Case()
  58.     print(FirstChoice)
  59.    
  60.  
  61. def Question():
  62.     Reset()
  63.     FirstChoice = input("What is your name?\n")
  64.     print("Hello, " + FirstChoice + ", and bye!")
  65.  
  66.  
  67. def EmailCheck():
  68.     Reset()
  69.     global IsEmail
  70.     global FirstChoice
  71.     IsEmail = False
  72.     FirstChoice = input("Enter your email!\n")
  73.     for i in range(0,(len(FirstChoice))):
  74.         StrNum = (int(i))
  75.         if FirstChoice[i] == "@":
  76.             IsEmail = True
  77.     return A()
  78.  
  79.    
  80. def A():
  81.    
  82.     if IsEmail == False:
  83.         print("This is not a Valid Email.")
  84.         EmailCheck()
  85.     else:
  86.         print("Thanks! Your Email has been verified (" + FirstChoice + ")")                                                                                                                                                            
  87.  
  88.  
  89. def StrLen():
  90.     Reset()
  91.     FirstChoice = input("Enter Words here\n")
  92.     StrNum = len(FirstChoice)
  93.     print(StrNum)
  94.  
  95.  
  96. def BackwardsSentence():
  97.     Reset()
  98.     FirstChoice = input("Enter sentence here\n")
  99.     StrNum = (int(len(FirstChoice)))
  100.     for i in range(0,StrNum):
  101.         StrNum2= StrNum - i - 1
  102.        
  103.         FinalString = FinalString + FirstChoice[StrNum2]
  104.     return print(FinalString)
  105.  
  106.  
  107. def Capitalise():
  108.     Reset()
  109.     FirstChoice = input("Enter sentence here\n")
  110.     StrNum = (int(len(FirstChoice)))
  111.     FinalChoice = FirstChoice[0].upper()
  112.     for i in range (1,StrNum):
  113.         FinalChoice = FinalChoice + FirstChoice[i].lower()
  114.     return FinalChoice
  115.     print(FinalChoice)
  116.  
  117. def RandNumMatrix():
  118.     Reset()
  119.     while Running:
  120.        for i in range(0,234):
  121.         StrNum2 = random.randint(0,((len(Alphabet)) - 19))
  122.         StrNum2 = Alphabet[StrNum2]
  123.         StrNum3 = random.randint(0,234)
  124.         StrNum4 = random.randint(0,((len(Alphabet)) - 19))
  125.         StrNum4 = Alphabet[StrNum4]
  126.         StrNum5 = random.randint(0,((len(Alphabet)) - 19))
  127.         StrNum5 = Alphabet[StrNum5]
  128.         StrNum6 = random.randint(0,((len(Alphabet)) - 19))
  129.         StrNum6 = Alphabet[StrNum6]
  130.         StrNum7 = random.randint(0,((len(Alphabet)) - 19))
  131.         StrNum7 = Alphabet[StrNum7]
  132.         StrNum8 = random.randint(0,((len(Alphabet)) - 19))
  133.         StrNum8 = Alphabet[StrNum8]
  134.  
  135.         StrNum9 = random.randint(0,((len(Alphabet)) - 19))
  136.         StrNum9 = Alphabet[StrNum9]
  137.         StrNum10 = random.randint(0,((len(Alphabet)) - 19))
  138.         StrNum10= Alphabet[StrNum10]
  139.         StrNum11 = random.randint(0,((len(Alphabet)) - 19))
  140.         StrNum11 = Alphabet[StrNum11]
  141.         StrNum12 = random.randint(0,((len(Alphabet)) - 19))
  142.         StrNum12 = Alphabet[StrNum12]
  143.         StrNum13 = random.randint(0,((len(Alphabet)) - 19))
  144.         StrNum13 = Alphabet[StrNum13]
  145.         StrNum14 = random.randint(0,((len(Alphabet)) - 19))
  146.         StrNum14 = Alphabet[StrNum14]
  147.         StrNum15 = random.randint(0,((len(Alphabet)) - 19))
  148.         StrNum15 = Alphabet[StrNum15]
  149.         FinalChoice = (" ")*StrNum3 + StrNum4 +  StrNum5  + StrNum6 +  StrNum7 + StrNum8 + StrNum9 + StrNum10+ StrNum11+ StrNum12+ StrNum13+ StrNum14+ StrNum15
  150.         print(FinalChoice)
  151.  
  152. def PatternPrint():
  153.     Reset()
  154.     while Running:
  155.         for i in range(0,400):
  156.             StrNum = i
  157.             StrNum2 = random.randint(0,((len(Alphabet)) - 1))
  158.             StrNum3 = StrNum2
  159.             StrNum2 = Alphabet[StrNum2]
  160.             print((StrNum2)*StrNum3)
  161.  
  162. def TeacherCodes():
  163.     #This calls the reset function, which clears all the variables so that it doesnt have errors when ran again.
  164.     Reset()
  165.     #This asks for an input, and sets it to the variable FirstChoice
  166.     FirstChoice = input("Enter Name here\n")
  167.     #this sets variable StrNum to the length of the input above
  168.     StrNum = (int(len(FirstChoice)))
  169.     #this sets the variable FinalChoice to a blank string.
  170.     FinalChoice = ("")
  171.     #this is a for-loop that runs for the length of StrNum, which is the length of the FirstChoice, the input.
  172.     #I do this so it can check the entire sentences letters in order.
  173.     for i in range (StrNum):
  174.         #this checks if there is a space in the word which lets it know it is a Surname and Forename.
  175.         if FirstChoice[i] == " ":
  176.             #this code puts the first letter of the first word, first letter of the second word,
  177.             #and last letter of the second word in a seperate string
  178.             FinalChoice = FinalChoice + FirstChoice[0]
  179.             FinalChoice = FinalChoice + FirstChoice[i+1]
  180.             FinalChoice = FinalChoice + FirstChoice[StrNum-1]
  181.             #this makes the word capital
  182.             FinalChoice = FinalChoice.upper()
  183.        
  184.     #this returns the final Teachercode.
  185.     return FinalChoice
  186.            
  187. def Vowels():
  188.     #This calls the reset function, which clears all the variables so that it doesnt have errors when ran again.
  189.     Reset()
  190.     #This asks for an input, and sets it to the variable FirstChoice
  191.     FirstChoice = input("Enter sentence here\n")
  192.     #this sets variable StrNum to the length of the input above
  193.     StrNum = (int(len(FirstChoice)))
  194.     #this sets the variable FinalChoice to a blank string.
  195.     FinalChoice = ("")
  196.     #this is a for-loop that runs for the length of StrNum, which is the length of the FirstChoice, the input.
  197.     #I do this so it can check the entire sentences letters in order.
  198.     for i in range (StrNum):
  199.         if FirstChoice[i] == "A" or FirstChoice[i] == "E" or FirstChoice[i] == "I" or FirstChoice[i] == "O" or FirstChoice[i] == "U" or FirstChoice[i] == "a" or FirstChoice[i] == "e" or FirstChoice[i] == "i"or FirstChoice[i] == "o" or FirstChoice[i] == "u":
  200.             FinalChoice = FinalChoice + FirstChoice[i]
  201.    
  202.     return FinalChoice
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement