Advertisement
wchalexander

Terminal 2.2

Aug 29th, 2018
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.35 KB | None | 0 0
  1. import random
  2. print("Welcome to the Alexander's Terminal\n Type help to see all available options \nand type help dir to see help about directory\n To clear just relaunch!\nTerminal 3.0 coming soon...!\n========================================================================================================\n To clear just relaunch!\n To see spanish version go see \njgoterris's terminal in webpage: gotxer.webnode.es\n When you are logged in (with the command 'login') you can play two games\nType:\n 'play guess the number' \n or\n 'play tic tac toe'")
  3. import os
  4. import sys
  5. import shutil
  6. while True:
  7. n=input("Command>")
  8.  
  9. if n=="help dir":
  10. print()
  11. print('Commands:\nhelp dir : See all directory files\nls : See files in the actual directory\nlsdir : See files of a selected directory\nsysinfo : Display system information\npyversion : Display python information\ncopyright : Display copyright\nlocation : See directory of the current folder\ncd : Change of directory\nmkdir : Create folder\nrmc : Erase folder\nrename : Rename folder/file')
  12. print()
  13.  
  14. elif n=='ls':
  15. print(os.listdir ())
  16.  
  17. elif n=='lsdir':
  18. directory=str(input('Directory: '))
  19. print(os.listdir (directory))
  20.  
  21. elif n=='sysinfo':
  22. print(os.uname ())
  23.  
  24. elif n=='pyversion':
  25. print(sys.version)
  26.  
  27. elif n=='copyright':
  28. print(sys.copyright)
  29.  
  30. elif n=='location':
  31. print(os.getcwd())
  32.  
  33. elif n=='cd':
  34. diectory=str(input('Directory: '))
  35. os.chdir(directory)
  36.  
  37. elif n=='mkdir':
  38. nc=str(input('Folder name: '))
  39. os.system('mkdir '+nc)
  40.  
  41. elif n=='rmc':
  42. nc=str(input('Folder name: '))
  43. shutil.rmtree(nc)
  44.  
  45. elif n=='rename':
  46. na=str(input('File name: '))
  47. nn=str(input('Rename file by: '))
  48. os.rename(na, nn)
  49.  
  50. elif n=='login2':
  51. usuario=str(input('User: '))
  52. contraseña=str(input('password: '))
  53. if usuario=='Gotxer' and contraseña=='7391':
  54. print('Hola Jesús')
  55.  
  56.  
  57.  
  58.  
  59. elif n=="exit":
  60. print("\nexiting...")
  61. break
  62. elif n=="Hello":
  63. print("Hello? Why are you asking this? This is a terminal.")
  64. elif n=="calculate":
  65. while True:
  66. b=float(input("Enter the first number\n>>>"))
  67. w=float(input("Enter the second number\n>>>"))
  68. x=input("Type:\n Multiplicate for a multiplication\n Divide for a division\n Add for an addition\n Sous for a soustraction\nAnd End to exit calculate mode\nType Help to see all available options in calculate mode\n>>>")
  69. if x=="Multiplicate" or "multiplicate":
  70. print("=",b*w, "\n")
  71. elif x=="Divide" or "divide":
  72. print("=",b/w, "\n")
  73. elif x=="Add" or "add":
  74. print("=",b+w, "\n")
  75. elif x=="Sous" or "sous":
  76. print("=",b-w, "\n")
  77. elif x=="Help":
  78. print("Multiplicate for a multiplication\n Divide for a division\n Add for an addition\n Sous for a soustraction\nAnd End to exit calculate mode\nType Help to see all available options in calculate mode\n")
  79. elif x=="End":
  80. print("Exiting calculate mode...")
  81. print("You exited the calculate mode")
  82. break
  83. else:
  84. print("Unknow command.")
  85. elif n=="help":
  86. print(" credits: to see the credits\n calculate: to open the calculator\n exit: to exit the terminal\n help dir: to see directory help\n login to login in your account if you don't have one use the guest account with no password\n")
  87. elif n=="credits":
  88. print("Created by Alexander Williams-Chamarro and jgoterris(Jesus Goterris Pitarch)\n")
  89. elif n=="login":
  90. while True:
  91. c=input("user: ")
  92. if c=="guest":
  93. while True:
  94. o=input("password: ")
  95. if o=="":
  96. print("Welcome, guest\n Type help to see more options when you are logged in")
  97. print("To logout type end until you see : Command>")
  98. t=input(">>>")
  99. while True:
  100.  
  101. if t=="play guess the number":
  102. maxn = 10
  103. n = random.randint(1, maxn)
  104. print('Welcome to guess the number game!')
  105. print('Guess the number from 1 to %d' % maxn)
  106. guess = None
  107. while guess != n:
  108. guess = int(input('Your try: '))
  109. if guess > n:
  110. print('Too high')
  111. if guess < n:
  112. print('Too low')
  113. else:
  114. print('Enter a valid number')
  115.  
  116.  
  117. print('Congratulations, you won!')
  118.  
  119. elif t=="end":
  120. break
  121.  
  122. elif t=="play tic tac toe":
  123. print('Bienvenido al tres en raya\n\nNormas:\nSi colocas el numero de un lugar ocupado, pasara al \nsiguiente jugador y no se colocara\nPara poner el numero de casilla primero columna y después \nfila\n')
  124. p1=str(input('Introduzca el nombre del primer jugador: '))
  125. p2=str(input('Introduzca el nombre del segundo jugador: '))
  126. f=1
  127. print()
  128. n1=['?','?','?']
  129. n2=['?','?','?']
  130. n3=['?','?','?']
  131. print(n1)
  132. print(n2)
  133. print(n3)
  134. while f==1:
  135. print()
  136. p=int(input(p1+' introduzca XY: '))
  137. #X
  138. if p==11:
  139. if n1[0]==('?'):
  140. n1[0]=('x')
  141. else:
  142. print('\nSitio ocupado\n')
  143. elif p==21:
  144. if n1[1]==('?'):
  145. n1[1]=('x')
  146. else:
  147. print('\nSitio ocupado\n')
  148. elif p==31:
  149. if n1[2]==('?'):
  150. n1[2]=('x')
  151. else:
  152. print('\nSitio ocupado\n')
  153. elif p==12:
  154. if n2[0]==('?'):
  155. n2[0]=('x')
  156. else:
  157. print('\nSitio ocupado\n')
  158. elif p==22:
  159. if n2[1]==('?'):
  160. n2[1]=('x')
  161. else:
  162. print('\nSitio ocupado\n')
  163. elif p==32:
  164. if n2[2]==('?'):
  165. n2[2]=('x')
  166. else:
  167. print('\nSitio ocupado\n')
  168. elif p==13:
  169. if n3[0]==('?'):
  170. n3[0]=('x')
  171. else:
  172. print('\nSitio ocupado\n')
  173. elif p==23:
  174. if n3[1]==('?'):
  175. n3[1]=('x')
  176. else:
  177. print('\nSitio ocupado\n')
  178. elif p==33:
  179. if n3[2]==('?'):
  180. n3[2]=('x')
  181. else:
  182. print('\nSitio ocupado\n')
  183.  
  184. print(n1)
  185. print(n2)
  186. print(n3)
  187. #Primera columna ganadora
  188. if n1[0]=='x':
  189. if n2[0]=='x':
  190. if n3[0]=='x':
  191. f=2
  192. print()
  193. print(p1+' ha ganado')
  194. input()
  195. break
  196. #Columna del medio ganadora
  197. if n1[1]=='x':
  198. if n2[1]=='x':
  199. if n3[1]=='x':
  200. f=2
  201. print()
  202. print(p1+' ha ganado')
  203. input()
  204. break
  205. #Columna del final ganadora
  206. if n1[2]=='x':
  207. if n2[2]=='x':
  208. if n3[2]=='x':
  209. f=2
  210. print()
  211. print(p1+' ha ganado')
  212. input()
  213. break
  214. #Primera fila ganadora
  215. if n1[0]=='x':
  216. if n1[1]=='x':
  217. if n1[2]=='x':
  218. f=2
  219. print()
  220. print(p1+' ha ganado')
  221. input()
  222. break
  223. #Segunda fila ganadora
  224. if n2[0]=='x':
  225. if n2[1]=='x':
  226. if n2[2]=='x':
  227. f=2
  228. print()
  229. print(p1+' ha ganado')
  230. input()
  231. break
  232. #Tercera fila ganadora
  233. if n3[0]=='x':
  234. if n3[1]=='x':
  235. if n3[2]=='x':
  236. f=2
  237. print()
  238. print(p1+' ha ganado')
  239. input()
  240. break
  241. #Diagonal arriba izquierda
  242. if n1[0]=='x':
  243. if n2[1]=='x':
  244. if n3[2]=='x':
  245. f=2
  246. print()
  247. print(p1+' ha ganado')
  248. input()
  249. break
  250. #Diagonal arriba derecha
  251. if n1[2]=='x':
  252. if n2[1]=='x':
  253. if n3[0]=='x':
  254. f=2
  255. print()
  256. print(p1+' ha ganado')
  257. input()
  258. break
  259.  
  260. print()
  261. p=int(input(p2+' introduzca XY: '))
  262. #O
  263. if p==11:
  264. if n1[0]==('?'):
  265. n1[0]=('o')
  266. else:
  267. print('\nSitio ocupado\n')
  268. elif p==21:
  269. if n1[1]==('?'):
  270. n1[1]=('o')
  271. else:
  272. print('\nSitio ocupado\n')
  273. elif p==31:
  274. if n1[2]==('?'):
  275. n1[2]=('o')
  276. else:
  277. print('\nSitio ocupado\n')
  278. elif p==12:
  279. if n2[0]==('?'):
  280. n2[0]=('o')
  281. else:
  282. print('\nSitio ocupado\n')
  283. elif p==22:
  284. if n2[1]==('?'):
  285. n2[1]=('o')
  286. else:
  287. print('\nSitio ocupado\n')
  288. elif p==32:
  289. if n2[2]==('?'):
  290. n2[2]=('o')
  291. else:
  292. print('\nSitio ocupado\n')
  293. elif p==13:
  294. if n3[0]==('?'):
  295. n3[0]=('o')
  296. else:
  297. print('\nSitio ocupado\n')
  298. elif p==23:
  299. if n3[1]==('?'):
  300. n3[1]=('o')
  301. else:
  302. print('\nSitio ocupado\n')
  303. elif p==33:
  304. if n3[2]==('?'):
  305. n3[2]=('o')
  306. else:
  307. print('\nSitio ocupado\n')
  308.  
  309. print(n1)
  310. print(n2)
  311. print(n3)
  312.  
  313. #Primera columna ganadora
  314. if n1[0]=='o':
  315. if n2[0]=='o':
  316. if n3[0]=='o':
  317. f=2
  318. print()
  319. print(p2+' ha ganado')
  320. input()
  321. break
  322. #Columna del medio ganadora
  323. if n1[1]=='o':
  324. if n2[1]=='o':
  325. if n3[1]=='o':
  326. f=2
  327. print()
  328. print(p2+' ha ganado')
  329. input()
  330. break
  331. #Columna del final ganadora
  332. if n1[2]=='o':
  333. if n2[2]=='o':
  334. if n3[2]=='o':
  335. f=2
  336. print()
  337. print(p2+' ha ganado')
  338. input()
  339. break
  340. #Primera fila ganadora
  341. if n1[0]=='o':
  342. if n1[1]=='o':
  343. if n1[2]=='o':
  344. f=2
  345. print()
  346. print(p2+' ha ganado')
  347. input()
  348. break
  349. #Segunda fila ganadora
  350. if n2[0]=='o':
  351. if n2[1]=='o':
  352. if n2[2]=='o':
  353. f=2
  354. print()
  355. print(p2+' ha ganado')
  356. input()
  357. break
  358. #Tercera fila ganadora
  359. if n3[0]=='o':
  360. if n3[1]=='o':
  361. if n3[2]=='o':
  362. f=2
  363. print()
  364. print(p2+' ha ganado')
  365. input()
  366. break
  367. #Diagonal arriba izquierda
  368. if n1[0]=='o':
  369. if n2[1]=='o':
  370. if n3[2]=='o':
  371. f=2
  372. print()
  373. print(p2+' ha ganado')
  374. input()
  375. break
  376. #Diagonal arriba derecha
  377. if n1[2]=='o':
  378. if n2[1]=='o':
  379. if n3[0]=='o':
  380. f=2
  381. print()
  382. print(p2+' ha ganado')
  383. input()
  384. break
  385. elif o=="end":
  386. break
  387.  
  388. elif c=="end":
  389. break
  390. elif c=="admin":
  391. m=input("password: ")
  392.  
  393. if m=="Manchi2015sg":
  394. print("\nWelcome administrator\n")
  395. v=input("What would you like to do?\n")
  396. if v=="Block":
  397. n=1
  398. while n==1:
  399. if n==1:
  400. print("Blocked Blocked Blocked Blocked Blocked Blocked Blocked Blocked Blocked")
  401. elif v=="play guess the number":
  402.  
  403. maxn = 10
  404. n = random.randint(1, maxn)
  405. print('Welcome to guess the number game!')
  406. print('Guess the number from 1 to %d' % maxn)
  407. guess = None
  408. while guess != n:
  409. guess = int(input('Your try: '))
  410. if guess > n:
  411. print('Too high')
  412. if guess < n:
  413. print('Too low')
  414. print('Congratulations, you won!')
  415.  
  416. elif v=="Secure mode":
  417. print("Yes, sir.\n We are in secure mode")
  418. a=input("Your orders>")
  419. if a=="Message":
  420. print("""crypted message ultracode: 110000 110010 110010 110011""")
  421. elif a=="end":
  422. break
  423. else:
  424. while True:
  425. print("Warning! Lockdown! ")
  426. else:
  427. print("Unknown user")
  428.  
  429. else:
  430. print("Unknown command\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement