Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.65 KB | None | 0 0
  1. "C:\Users\Jacob Bode\PycharmProjects\Test\venv\Scripts\python.exe" "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.1\helpers\pydev\pydevconsole.py" --mode=client --port=63662
  2.  
  3. import sys; print('Python %s on %s' % (sys.version, sys.platform))
  4. sys.path.extend(['C:/Pycharm Projects'])
  5.  
  6. PyDev console: starting.
  7.  
  8. Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
  9. >>> from math import sqrt
  10. ... def prime_tester_with_input():
  11. ...
  12. ... is_prime = True
  13. ...
  14. ... x = input("What number would you like to test?")
  15. ...
  16. ... x = abs(int(x))
  17. ...
  18. ... if x > 1:
  19. ...
  20. ... for i in range(2, x):
  21. ...
  22. ... print("Does " + str(i) + " go into " + str(x) + "?")
  23. ...
  24. ... if x % i == 0:
  25. ...
  26. ... print("Yes")
  27. ...
  28. ... is_prime = False
  29. ...
  30. ... break
  31. ...
  32. ... else:
  33. ...
  34. ... print("No")
  35. ...
  36. ... elif x == 1:
  37. ...
  38. ... print("1 is a prime number")
  39. ...
  40. ... else:
  41. ...
  42. ... print("0 is neither prime nor composite")
  43. ...
  44. ... if is_prime:
  45. ...
  46. ... print(str(x) + " is prime")
  47. ...
  48. ... else:
  49. ...
  50. ... print(str(x) + " is not prime")
  51. ...
  52. ... def prime_tester(x):
  53. ...
  54. ... if int(x) != x:
  55. ...
  56. ... print("Decimals cannot be prime or composite")
  57. ...
  58. ... else:
  59. ...
  60. ... is_prime = True
  61. ...
  62. ... absolute_valued = abs(int(x))
  63. ...
  64. ... if absolute_valued > 1:
  65. ...
  66. ... for i in range(2, absolute_valued):
  67. ...
  68. ... if x % i == 0:
  69. ...
  70. ... is_prime = False
  71. ...
  72. ... break
  73. ...
  74. ... if is_prime:
  75. ...
  76. ... print(str(x) + " is prime")
  77. ...
  78. ... else:
  79. ...
  80. ... print(str(x) + " is composite")
  81. ...
  82. ... elif absolute_valued == 1:
  83. ...
  84. ... print(str(x) + " is a prime number")
  85. ...
  86. ... else:
  87. ...
  88. ... print("0 is neither prime nor composite")
  89. ...
  90. ... def number_info():
  91. ...
  92. ... num = float(input("What number would you like the information for? "))
  93. ...
  94. ... even_tester(num)
  95. ...
  96. ... prime_tester(num)
  97. ...
  98. ... square_root_finder(num)
  99. ...
  100. ... x_squared(num)
  101. ...
  102. ... def even_tester(x):
  103. ...
  104. ... if int(x) != x:
  105. ...
  106. ... print("Decimals are neither even or odd")
  107. ...
  108. ... else:
  109. ...
  110. ... is_even = False
  111. ...
  112. ... if x % 2 == 0:
  113. ...
  114. ... is_even = True
  115. ...
  116. ... if is_even:
  117. ...
  118. ... print(str(x) + " is even")
  119. ...
  120. ... else:
  121. ...
  122. ... print(str(x) + " is odd")
  123. ...
  124. ... def x_squared(x):
  125. ...
  126. ... square = x ** 2
  127. ...
  128. ... print("The square of " + str(x) + " is " + str(square))
  129. ...
  130. ... def square_root_finder(x):
  131. ...
  132. ... if x >= 0:
  133. ...
  134. ... square_root = sqrt(x)
  135. ...
  136. ... print("The square root of " + str(x) + " is " + str(square_root))
  137. ...
  138. ... else:
  139. ...
  140. ... print("Negative numbers cannot have square roots")
  141. ...
  142. >>> def factor_finder(x):
  143. ... factors = [
  144. ...
  145. ... ]
  146. ... for i in range(0,x):
  147. ... if x % i == 0:
  148. ... factors.append(i)
  149. ... print(factors)
  150. ...
  151. ...
  152. ...
  153. >>> factor_finder(5)
  154. Traceback (most recent call last):
  155. File "<input>", line 1, in <module>
  156. File "<input>", line 6, in factor_finder
  157. ZeroDivisionError: integer division or modulo by zero
  158. >>> def factor_finder(x):
  159. ... factors = [
  160. ...
  161. ... ]
  162. ... for i in range(1,x + 1):
  163. ... if x % i == 0:
  164. ... factors.append(i)
  165. ... print(factors)
  166. ...
  167. >>> factor_finder(5)
  168. [1, 5]
  169. >>>
  170. >>> factor_finder(4)
  171. [1, 2, 4]
  172. >>> def factor_finder(x):
  173. ... factors = [
  174. ...
  175. ... ]
  176. ... for i in range(1, x + 1):
  177. ... if x % i == 0:
  178. ... factors.append(i)
  179. ... print("The factors of " + str(x) + " are " + factors)
  180. ...
  181. >>> factor_finder(4)
  182. Traceback (most recent call last):
  183. File "<input>", line 1, in <module>
  184. File "<input>", line 8, in factor_finder
  185. TypeError: can only concatenate str (not "list") to str
  186. >>> def factor_finder(x):
  187. ... factors = [
  188. ... ]
  189. ... for i in range(1, x + 1):
  190. ... if x % i == 0:
  191. ... factors.append(i)
  192. ... print("The factors of " + str(x) + " are " + str(factors))
  193. ...
  194. >>> factor_finder(4)
  195. The factors of 4 are [1, 2, 4]
  196. >>> def number_info():
  197. ... num = float(input("What number would you like the information for? "))
  198. ... even_tester(num)
  199. ... prime_tester(num)
  200. ... square_root_finder(num)
  201. ... x_squared(num)
  202. ... factor_finder(num)
  203. ...
  204. >>> number_info()
  205. What number would you like the information for? >? 5
  206. 5.0 is odd
  207. 5.0 is prime
  208. The square root of 5.0 is 2.23606797749979
  209. The square of 5.0 is 25.0
  210. Traceback (most recent call last):
  211. File "<input>", line 1, in <module>
  212. File "<input>", line 7, in number_info
  213. File "<input>", line 4, in factor_finder
  214. TypeError: 'float' object cannot be interpreted as an integer
  215. >>> def factor_finder(x):
  216. ... if int(x) == x:
  217. ... x = int(x)
  218. ... else:
  219. ... print("Decimals do not have any factors")
  220. ... factors = [
  221. ... ]
  222. ... for i in range(1, x + 1):
  223. ... if x % i == 0:
  224. ... factors.append(i)
  225. ... print("The factors of " + str(x) + " are " + str(factors))
  226. ...
  227. >>> number_info()
  228. What number would you like the information for? >? 5
  229. 5.0 is odd
  230. 5.0 is prime
  231. The square root of 5.0 is 2.23606797749979
  232. The square of 5.0 is 25.0
  233. The factors of 5 are [1, 5]
  234. >>> number_info()
  235. What number would you like the information for? >? 3.4
  236. Decimals are neither even or odd
  237. Decimals cannot be prime or composite
  238. The square root of 3.4 is 1.8439088914585775
  239. The square of 3.4 is 11.559999999999999
  240. Decimals do not have any factors
  241. Traceback (most recent call last):
  242. File "<input>", line 1, in <module>
  243. File "<input>", line 7, in number_info
  244. File "<input>", line 8, in factor_finder
  245. TypeError: 'float' object cannot be interpreted as an integer
  246. >>> def factor_finder(x):
  247. ... if int(x) == x:
  248. ... x = int(x)
  249. ... factors = [
  250. ... ]
  251. ... for i in range(1, x + 1):
  252. ... if x % i == 0:
  253. ... factors.append(i)
  254. ... print("The factors of " + str(x) + " are " + str(factors))
  255. ... else:
  256. ... print("Decimals do not have any factors")
  257. ...
  258. >>> number_info()
  259. What number would you like the information for? >? 3.5
  260. Decimals are neither even or odd
  261. Decimals cannot be prime or composite
  262. The square root of 3.5 is 1.8708286933869707
  263. The square of 3.5 is 12.25
  264. Decimals do not have any factors
  265. >>> def factor_finder(x):
  266. ... if int(x) == x:
  267. ... x = int(x)
  268. ... factors = [
  269. ... ]
  270. ... if x > 0:
  271. ... for i in range(1, x + 1):
  272. ... if x % i == 0:
  273. ... factors.append(i)
  274. ... print("The factors of " + str(x) + " are " + str(factors))
  275. ... elif x == 0:
  276. ... print("Zero does not have any factors")
  277. ... else:
  278. ... x = abs(x)
  279. ... for i in range(1, x + 1):
  280. ... if x % i == 0:
  281. ... factors.append(i)
  282. ... opposite = 0 - i
  283. ... factors.append(opposite)
  284. ... print("The factors of " + str(x) + " are " + str(factors))
  285. ... else:
  286. ... print("Decimals do not have any factors")
  287. ...
  288. >>> number_info()
  289. What number would you like the information for? >? 5
  290. 5.0 is odd
  291. 5.0 is prime
  292. The square root of 5.0 is 2.23606797749979
  293. The square of 5.0 is 25.0
  294. The factors of 5 are [1, 5]
  295. >>> number_info()
  296. What number would you like the information for? >? 1
  297. 1.0 is odd
  298. 1.0 is a prime number
  299. The square root of 1.0 is 1.0
  300. The square of 1.0 is 1.0
  301. The factors of 1 are [1]
  302. >>> def factor_finder(x):
  303. ... if int(x) == x:
  304. ... x = int(x)
  305. ... factors = [
  306. ... ]
  307. ... if x > 0:
  308. ... for i in range(1, x + 1):
  309. ... if x % i == 0:
  310. ... factors.append(i)
  311. ... print("The factors of " + str(x) + " are " + str(factors))
  312. ... elif x == 0:
  313. ... print("Zero does not have any factors")
  314. ... else:
  315. ... x = abs(x)
  316. ... for i in range(1, x + 1):
  317. ... if x % i == 0:
  318. ... factors.append(i)
  319. ... opposite = 0 - i
  320. ... factors.append(opposite)
  321. ... print("The factors of " + str(x) + " are " + str(factors))
  322. ... else:
  323. ... print("Decimals do not have any factors")
  324. ...
  325. >>> number_info()
  326. What number would you like the information for? >? 0
  327. 0.0 is even
  328. 0 is neither prime nor composite
  329. The square root of 0.0 is 0.0
  330. The square of 0.0 is 0.0
  331. Zero does not have any factors
  332. >>> number_info()
  333. What number would you like the information for? >? -1
  334. -1.0 is odd
  335. -1.0 is a prime number
  336. Negative numbers cannot have square roots
  337. The square of -1.0 is 1.0
  338. The factors of 1 are [1, -1]
  339. >>> number_info()
  340. What number would you like the information for? >? -5
  341. -5.0 is odd
  342. -5.0 is prime
  343. Negative numbers cannot have square roots
  344. The square of -5.0 is 25.0
  345. The factors of 5 are [1, -1, 5, -5]
  346. >>> number_info()
  347. What number would you like the information for? >? 15
  348. 15.0 is odd
  349. 15.0 is composite
  350. The square root of 15.0 is 3.872983346207417
  351. The square of 15.0 is 225.0
  352. The factors of 15 are [1, 3, 5, 15]
  353. >>> number_info()
  354. What number would you like the information for? >? -15
  355. -15.0 is odd
  356. -15.0 is composite
  357. Negative numbers cannot have square roots
  358. The square of -15.0 is 225.0
  359. The factors of 15 are [1, -1, 3, -3, 5, -5, 15, -15]
  360. >>> number_info()
  361. What number would you like the information for? >? -144
  362. -144.0 is even
  363. -144.0 is composite
  364. Negative numbers cannot have square roots
  365. The square of -144.0 is 20736.0
  366. The factors of 144 are [1, -1, 2, -2, 3, -3, 4, -4, 6, -6, 8, -8, 9, -9, 12, -12, 16, -16, 18, -18, 24, -24, 36, -36, 48, -48, 72, -72, 144, -144]
  367. >>> def number_info():
  368. ... choice = input("Would you like to know"
  369. ... "1: If it's even/odd"
  370. ... "2: If it's prime/composite"
  371. ... "3: The square root"
  372. ... "4: The square of the number"
  373. ... "5: The factors of the number"
  374. ... "6: All of the above)"
  375. ... num = float(input("What number would you like the information for? "))
  376. ... even_tester(num)
  377. ... prime_tester(num)
  378. ... square_root_finder(num)
  379. ... x_squared(num)
  380. ... factor_finder(num)
  381. ...
  382. File "<input>", line 9
  383. num = float(input("What number would you like the information for? "))
  384. ^
  385. SyntaxError: invalid syntax
  386. >>> def number_info():
  387. ... choice = input("Would you like to know"
  388. ... "1: If it's even/odd"
  389. ... "2: If it's prime/composite"
  390. ... "3: The square root"
  391. ... "4: The square of the number"
  392. ... "5: The factors of the number"
  393. ... "6: All of the above")
  394. ... num = float(input("What number would you like the information for? "))
  395. ... even_tester(num)
  396. ... prime_tester(num)
  397. ... square_root_finder(num)
  398. ... x_squared(num)
  399. ... factor_finder(num)
  400. ...
  401. >>> number_info()
  402. Would you like to know1: If it's even/odd2: If it's prime/composite3: The square root4: The square of the number5: The factors of the number6: All of the above>? 6
  403. What number would you like the information for? >? 6
  404. 6.0 is even
  405. 6.0 is composite
  406. The square root of 6.0 is 2.449489742783178
  407. The square of 6.0 is 36.0
  408. The factors of 6 are [1, 2, 3, 6]
  409. >>> def number_info():
  410. ... choice = input("Would you like to know "
  411. ... "1: If it's even/odd "
  412. ... "2: If it's prime/composite "
  413. ... "3: The square root "
  414. ... "4: The square of the number "
  415. ... "5: The factors of the number "
  416. ... "6: All of the above ")
  417. ... num = float(input("What number would you like the information for? "))
  418. ... even_tester(num)
  419. ... prime_tester(num)
  420. ... square_root_finder(num)
  421. ... x_squared(num)
  422. ... factor_finder(num)
  423. ...
  424. >>> number_info()
  425. Would you like to know 1: If it's even/odd 2: If it's prime/composite 3: The square root 4: The square of the number 5: The factors of the number 6: All of the above >? 5
  426. What number would you like the information for? >? 5
  427. 5.0 is odd
  428. 5.0 is prime
  429. The square root of 5.0 is 2.23606797749979
  430. The square of 5.0 is 25.0
  431. The factors of 5 are [1, 5]
  432. >>> def number_info():
  433. ... num = float(input("What number would you like the information for? "))
  434. ... choice = input("Would you like to know "
  435. ... "1: If it's even/odd "
  436. ... "2: If it's prime/composite "
  437. ... "3: The square root "
  438. ... "4: The square of the number "
  439. ... "5: The factors of the number "
  440. ... "6: All of the above ")
  441. ... if choice == 1:
  442. ... even_tester(num)
  443. ... elif choice == 2:
  444. ... prime_tester(num)
  445. ... elif choice == 3:
  446. ... square_root_finder(num)
  447. ... elif choice == 4:
  448. ... x_squared(num)
  449. ... elif choice == 5:
  450. ... factor_finder(num)
  451. ... elif choice == 6:
  452. ... even_tester(num)
  453. ... prime_tester(num)
  454. ... square_root_finder(num)
  455. ... x_squared(num)
  456. ... factor_finder(num)
  457. ... else:
  458. ... print("That wasn't an option")
  459. ...
  460. >>> number_info()
  461. What number would you like the information for? >? 5
  462. Would you like to know 1: If it's even/odd 2: If it's prime/composite 3: The square root 4: The square of the number 5: The factors of the number 6: All of the above >? 6
  463. That wasn't an option
  464. >>> def number_info():
  465. ... num = float(input("What number would you like the information for? "))
  466. ... choice = input("Would you like to know "
  467. ... "1: If it's even/odd "
  468. ... "2: If it's prime/composite "
  469. ... "3: The square root "
  470. ... "4: The square of the number "
  471. ... "5: The factors of the number "
  472. ... "6: All of the above ")
  473. ... if choice == "1":
  474. ... even_tester(num)
  475. ... elif choice == "2":
  476. ... prime_tester(num)
  477. ... elif choice == "3":
  478. ... square_root_finder(num)
  479. ... elif choice == "4":
  480. ... x_squared(num)
  481. ... elif choice == "5":
  482. ... factor_finder(num)
  483. ... elif choice == "6":
  484. ... even_tester(num)
  485. ... prime_tester(num)
  486. ... square_root_finder(num)
  487. ... x_squared(num)
  488. ... factor_finder(num)
  489. ... else:
  490. ... print("That wasn't an option")
  491. ...
  492. >>> number_info()
  493. What number would you like the information for? >? 5
  494. Would you like to know 1: If it's even/odd 2: If it's prime/composite 3: The square root 4: The square of the number 5: The factors of the number 6: All of the above >? 5
  495. The factors of 5 are [1, 5]
  496. >>> def number_info():
  497. ... num = float(input("What number would you like the information for? "))
  498. ... choice = input("Would you like to know "
  499. ... "1: If it's even/odd "
  500. ... "2: If it's prime/composite "
  501. ... "3: The square root "
  502. ... "4: The square of the number "
  503. ... "5: The factors of the number "
  504. ... "6: All of the above ")
  505. ... choices = [
  506. ...
  507. ... ]
  508. ... for i in range(0, len(choice)):
  509. ... choices.append(choice[i])
  510. ... for i in range(0,len(choices)):
  511. ... if choices[i] == "1":
  512. ... even_tester(num)
  513. ... elif choices[i] == "2":
  514. ... prime_tester(num)
  515. ... elif choices[i] == "3":
  516. ... square_root_finder(num)
  517. ... elif choices[i] == "4":
  518. ... x_squared(num)
  519. ... elif choices[i] == "5":
  520. ... factor_finder(num)
  521. ... elif choices[i] == "6":
  522. ... even_tester(num)
  523. ... prime_tester(num)
  524. ... square_root_finder(num)
  525. ... x_squared(num)
  526. ... factor_finder(num)
  527. ... else:
  528. ... print("That wasn't an option")
  529. ...
  530. >>> number_info()
  531. What number would you like the information for? >? 5
  532. Would you like to know 1: If it's even/odd 2: If it's prime/composite 3: The square root 4: The square of the number 5: The factors of the number 6: All of the above >? 12
  533. 5.0 is odd
  534. 5.0 is prime
  535. >>> def number_info():
  536. ... factor_already = False
  537. ... squared_already = False
  538. ... root_already = False
  539. ... prime_already = False
  540. ... even_already = False
  541. ... num = float(input("What number would you like the information for? "))
  542. ... choice = input(
  543. ... "Would you like to know, if you wish to do multiple, put the numbers in a row as a big number ex. 1235 "
  544. ... "1: If it's even/odd "
  545. ... "2: If it's prime/composite "
  546. ... "3: The square root "
  547. ... "4: The square of the number "
  548. ... "5: The factors of the number "
  549. ... "6: All of the above ")
  550. ... choices = [
  551. ...
  552. ... ]
  553. ... for i in range(0, len(choice)):
  554. ... choices.append(choice[i])
  555. ... for i in range(0, len(choices)):
  556. ... if choices[i] == "1":
  557. ... if not even_already:
  558. ... even_tester(num)
  559. ... even_already = True
  560. ... elif choices[i] == "2":
  561. ... if not prime_already:
  562. ... prime_tester(num)
  563. ... prime_already = True
  564. ... elif choices[i] == "3":
  565. ... if not root_already:
  566. ... square_root_finder(num)
  567. ... root_already = True
  568. ... elif choices[i] == "4":
  569. ... if not squared_already:
  570. ... x_squared(num)
  571. ... squared_already = True
  572. ... elif choices[i] == "5":
  573. ... if not factor_already:
  574. ... factor_finder(num)
  575. ... factor_already = True
  576. ... elif choices[i] == "6":
  577. ... if not even_already:
  578. ... even_tester(num)
  579. ... even_already = True
  580. ... if not prime_already:
  581. ... prime_tester(num)
  582. ... prime_already = True
  583. ... if not root_already:
  584. ... square_root_finder(num)
  585. ... root_already = True
  586. ... if not squared_already:
  587. ... x_squared(num)
  588. ... squared_already = True
  589. ... if not factor_already:
  590. ... factor_finder(num)
  591. ... factor_already = True
  592. ... else:
  593. ... print("That wasn't an option")
  594. ...
  595. >>> number_info
  596. <function number_info at 0x0467A3D8>
  597. >>> 5
  598. 5
  599. >>> number_info()
  600. What number would you like the information for? >? 4
  601. Would you like to know, if you wish to do multiple, put the numbers in a row as a big number ex. 1235 1: If it's even/odd 2: If it's prime/composite 3: The square root 4: The square of the number 5: The factors of the number 6: All of the above >? 1325
  602. 4.0 is even
  603. The square root of 4.0 is 2.0
  604. 4.0 is composite
  605. The factors of 4 are [1, 2, 4]
  606. >>> def number_info():
  607. ... factor_already = False
  608. ... squared_already = False
  609. ... root_already = False
  610. ... prime_already = False
  611. ... even_already = False
  612. ... num = float(input("What number would you like the information for? "))
  613. ... print("1: If it's even/odd")
  614. ... print("2: If it's prime/composite")
  615. ... print("3: The square root")
  616. ... print("4: The square of the number")
  617. ... print("5: The factors of the number")
  618. ... print("6: All of the above")
  619. ... choice = input(
  620. ... "Would you like to know, if you wish to do multiple, put the numbers in a row as a big number ex. 1235 ")
  621. ... choices = [
  622. ... ]
  623. ... for i in range(0, len(choice)):
  624. ... choices.append(choice[i])
  625. ... for i in range(0, len(choices)):
  626. ... if choices[i] == "1":
  627. ... if not even_already:
  628. ... even_tester(num)
  629. ... even_already = True
  630. ... elif choices[i] == "2":
  631. ... if not prime_already:
  632. ... prime_tester(num)
  633. ... prime_already = True
  634. ... elif choices[i] == "3":
  635. ... if not root_already:
  636. ... square_root_finder(num)
  637. ... root_already = True
  638. ... elif choices[i] == "4":
  639. ... if not squared_already:
  640. ... x_squared(num)
  641. ... squared_already = True
  642. ... elif choices[i] == "5":
  643. ... if not factor_already:
  644. ... factor_finder(num)
  645. ... factor_already = True
  646. ... elif choices[i] == "6":
  647. ... if not even_already:
  648. ... even_tester(num)
  649. ... even_already = True
  650. ... if not prime_already:
  651. ... prime_tester(num)
  652. ... prime_already = True
  653. ... if not root_already:
  654. ... square_root_finder(num)
  655. ... root_already = True
  656. ... if not squared_already:
  657. ... x_squared(num)
  658. ... squared_already = True
  659. ... if not factor_already:
  660. ... factor_finder(num)
  661. ... factor_already = True
  662. ... else:
  663. ... print("That wasn't an option")
  664. ...
  665. >>> number_info()
  666. What number would you like the information for? >? 5
  667. 1: If it's even/odd
  668. 2: If it's prime/composite
  669. 3: The square root
  670. 4: The square of the number
  671. 5: The factors of the number
  672. 6: All of the above
  673. Would you like to know, if you wish to do multiple, put the numbers in a row as a big number ex. 1235 >? 134
  674. 5.0 is odd
  675. The square root of 5.0 is 2.23606797749979
  676. The square of 5.0 is 25.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement