Last login: Mon Sep 14 08:55:06 on ttys001 The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. (base) MAC:Mon Sep 14:09:00:dg> cd (base) MAC:Mon Sep 14:09:00:~> cd T1/4260 -bash: cd: T1/4260: No such file or directory (base) MAC:Mon Sep 14:09:00:~> cd (base) MAC:Mon Sep 14:09:00:~> cd 20202021/T1/4260/ (base) MAC:Mon Sep 14:09:01:4260> ls interfaces ovipositor.jpg students week1 week2 week3 (base) MAC:Mon Sep 14:09:01:4260> mkdir bigFraction (base) MAC:Mon Sep 14:09:01:4260> cd bigFraction/ (base) MAC:Mon Sep 14:09:01:bigFraction> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> BigInteger a = BigInteger.valueOf(7776); a ==> 7776 jshell> BigInteger b = BigInteger.valueOf(1048576); b ==> 1048576 jshell> a.gcd(b) $3 ==> 32 jshell> BigInteger A = a.divide(a.gcd(b)) A ==> 243 jshell> BigInteger B = b.divide(a.gcd(b)) B ==> 32768 jshell> A.gcd(B) $6 ==> 1 jshell> A < B | Error: | bad operand types for binary operator '<' | first type: java.math.BigInteger | second type: java.math.BigInteger | A < B | ^---^ jshell> a.compareTo(b) $7 ==> -1 jshell> A.compareTo(B) $8 ==> -1 jshell> b.compareTo(a) $9 ==> 1 jshell> jshell> /exit | Goodbye (base) MAC:Mon Sep 14:09:38:bigFraction> ls (base) MAC:Mon Sep 14:09:38:bigFraction> vi bigInt.txt (base) MAC:Mon Sep 14:09:38:bigFraction> ls bigInt.txt (base) MAC:Mon Sep 14:09:38:bigFraction> B (base) MAC:Mon Sep 14:09:38:4240> ls convert keethan.txt listGames roster.csv stringPlay vpn.txt functions lab1 names.txt roster.txt students week2 (base) MAC:Mon Sep 14:09:38:4240> mkdir week3 (base) MAC:Mon Sep 14:09:38:4240> cd week3 (base) MAC:Mon Sep 14:09:38:week3> ls (base) MAC:Mon Sep 14:09:38:week3> python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def square(x): return x*x ... >>> square(5) 25 >>> cows = square >>> cows(5) 25 >>> # a function name is a variable name. ... # this name points at the code in memory that runs the function. ... >>> type(cows) >>> (base) MAC:Mon Sep 14:09:43:week3> vi table.py (base) MAC:Mon Sep 14:09:50:week3> python table.py 525 (base) MAC:Mon Sep 14:09:50:week3> !vi vi table.py (base) MAC:Mon Sep 14:09:56:week3> python table.py 525 [1, 2, 3, 4, 5, 6] (base) MAC:Mon Sep 14:09:56:week3> !vi vi table.py (base) MAC:Mon Sep 14:09:56:week3> !p python table.py 525 None (base) MAC:Mon Sep 14:09:56:week3> !vi vi table.py (base) MAC:Mon Sep 14:09:56:week3> !p python table.py 525
xf(x)
11
24
39
416
525
636
(base) MAC:Mon Sep 14:09:56:week3> !vi vi table.py (base) MAC:Mon Sep 14:09:58:week3> python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> def square(x): return x*x ... >>> str(square( ... )) Traceback (most recent call last): File "", line 1, in TypeError: square() missing 1 required positional argument: 'x' >>> str(square) '' >>> (base) MAC:Mon Sep 14:10:00:week3> ls table.py (base) MAC:Mon Sep 14:10:00:week3> vi table.py (base) MAC:Mon Sep 14:10:00:week3> python table.py 525
xf(x)
11
24
39
416
525
636
xf(x)
0.10.010000000000000002
0.20.04000000000000001
0.30.09
0.40.16000000000000003
0.50.25
0.60.36
(base) MAC:Mon Sep 14:10:00:week3> ls table.py (base) MAC:Mon Sep 14:10:02:week3> vi pancakes.py (base) MAC:Mon Sep 14:10:03:week3> python pancakes.py {'x': 5} {'x': 5} 125 {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7f9fd8dc42d0>, '__spec__': None, '__annotations__': {}, '__builtins__': , '__file__': 'pancakes.py', '__cached__': None, 'square': , 'cube': , 'x': 5} (base) MAC:Mon Sep 14:10:04:week3> vi build.py (base) MAC:Mon Sep 14:14:22:week3> !p python pancakes.py {'x': 5} {'x': 5} 125 {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x7fb25d4c42d0>, '__spec__': None, '__annotations__': {}, '__builtins__': , '__file__': 'pancakes.py', '__cached__': None, 'square': , 'cube': , 'x': 5} (base) MAC:Mon Sep 14:14:22:week3> python build.py 525
xf(x)
11
24
39
416
525
636
749
864
981
xf(x)
0.10.010000000000000002
0.20.04000000000000001
0.30.09
0.450.2025
0.60.36
0.90.81
0.950.9025
(base) MAC:Mon Sep 14:14:22:week3> !vi vi build.py (base) MAC:Mon Sep 14:14:24:week3> ls build.py pancakes.py table.py (base) MAC:Mon Sep 14:14:24:week3> vi build.py (base) MAC:Mon Sep 14:14:26:week3> !p python build.py 525
xf(x)
11
24
39
416
525
636
749
864
981
xf(x)
0.10.010000000000000002
0.20.04000000000000001
0.30.09
0.450.2025
0.60.36
0.90.81
0.950.9025
xf(x)
00.0
10.01745240643728351
20.03489949670250097
30.05233595624294383
40.0697564737441253
50.08715574274765817
60.10452846326765346
70.12186934340514748
80.13917310096006544
90.15643446504023087
100.17364817766693033
110.1908089953765448
120.20791169081775931
130.224951054343865
140.24192189559966773
150.25881904510252074
160.27563735581699916
170.29237170472273677
180.3090169943749474
190.32556815445715664
(base) MAC:Mon Sep 14:14:26:week3> (base) MAC:Mon Sep 14:14:26:week3> !vi vi build.py (base) MAC:Mon Sep 14:14:27:week3> vi index.php (base) MAC:Mon Sep 14:14:27:week3> ls babies.py file last.txt showList.py build.py foo.py pancakes.py table.py (base) MAC:Wed Sep 16:08:39:week3> cd .. (base) MAC:Wed Sep 16:08:39:4240> ls convert keethan.txt listGames roster.csv stringPlay vpn.txt week3 functions lab1 names.txt roster.txt students week2 (base) MAC:Wed Sep 16:08:39:4240> A (base) MAC:Wed Sep 16:08:39:4260> cd interfaces/ (base) MAC:Wed Sep 16:08:39:interfaces> ls Circle.class Rectangle.class Shape.class Triangle.class session.txt Circle.java Rectangle.java Shape.java Triangle.java (base) MAC:Wed Sep 16:08:39:interfaces> sftp utility0 Connected to utility0. sftp> cd public_html/currentClasses/4260/Sep sftp> cd 16Sep20 sftp> get *.java Fetching /home/morrison/public_html/currentClasses/4260/Sep/16Sep20/Circle.java to Circle.java /home/morrison/public_html/currentClasses/4260/Sep/16S 100% 579 5.8KB/s 00:00 Fetching /home/morrison/public_html/currentClasses/4260/Sep/16Sep20/Polygon.java to Polygon.java /home/morrison/public_html/currentClasses/4260/Sep/16S 100% 70 0.7KB/s 00:00 Fetching /home/morrison/public_html/currentClasses/4260/Sep/16Sep20/Rectangle.java to Rectangle.java /home/morrison/public_html/currentClasses/4260/Sep/16S 100% 819 8.0KB/s 00:00 Fetching /home/morrison/public_html/currentClasses/4260/Sep/16Sep20/Shape.java to Shape.java /home/morrison/public_html/currentClasses/4260/Sep/16S 100% 114 1.1KB/s 00:00 Fetching /home/morrison/public_html/currentClasses/4260/Sep/16Sep20/Triangle.java to Triangle.java /home/morrison/public_html/currentClasses/4260/Sep/16S 100% 930 9.3KB/s 00:00 sftp> quit (base) MAC:Wed Sep 16:08:40:interfaces> ls Circle.class Polygon.java Rectangle.java Shape.java Triangle.java Circle.java Rectangle.class Shape.class Triangle.class session.txt (base) MAC:Wed Sep 16:08:40:interfaces> java *.java error: can't find main(String[]) method in class: Circle (base) MAC:Wed Sep 16:08:40:interfaces> javac *.java (base) MAC:Wed Sep 16:08:40:interfaces> Shape s = new Circle(5); -bash: syntax error near unexpected token `(' (base) MAC:Wed Sep 16:08:40:interfaces> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> /open Shape.java jshell> /open Circle.java jshell> /open Rectangle.java | Error: | cannot find symbol | symbol: class Polygon | public class Rectangle implements Polygon | ^-----^ | Error: | method does not override or implement a method from a supertype | @Override | ^-------^ | Error: | method does not override or implement a method from a supertype | @Override | ^-------^ | Error: | method does not override or implement a method from a supertype | @Override | ^-------^ | Error: | method does not override or implement a method from a supertype | @Override | ^-------^ jshell> /open Polygon.java jshell> /open Rectangle.java jshell> /open Triangle.java jshell> Shape s = new Circle(5); s ==> Circle(5.0) jshell> s.area( ...> ) $7 ==> 78.53981633974483 jshell> Polygon t = new Circle(5); | Error: | incompatible types: Circle cannot be converted to Polygon | Polygon t = new Circle(5); | ^-----------^ jshell> Polygon t = new Rectangle(6,8); t ==> Rectangle(8.0, 6.0) jshell> t.area() $9 ==> 48.0 jshell> t.numSides() $10 ==> 4 jshell> Shape u = new Rectangle(5,5);; u ==> Rectangle(5.0, 5.0) jshell> u.area() $13 ==> 25.0 jshell> u.numSides() | Error: | cannot find symbol | symbol: method numSides() | u.numSides() | ^--------^ jshell> /exit | Goodbye (base) MAC:Wed Sep 16:09:00:interfaces> python Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> f = lambda x: x[0] >>> >>> type(f) >>> f("cats") 'c' >>> f([2,3,3]) 2 >>> # this is x -> x[0] ... >>> f(range(2,4)) 2 >>> (lambda x:x*x)(6) 36 >>> quit() (base) MAC:Wed Sep 16:09:03:interfaces> vi table.py (base) MAC:Wed Sep 16:09:07:interfaces> python table.py (base) MAC:Wed Sep 16:09:07:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:08:interfaces> python table.py File "table.py", line 13 ^ SyntaxError: unexpected EOF while parsing (base) MAC:Wed Sep 16:09:09:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:09:interfaces> !p python table.py None (base) MAC:Wed Sep 16:09:09:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:09:interfaces> !p python table.py
xf(x)
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
{item}{f(item)}
(base) MAC:Wed Sep 16:09:09:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:09:interfaces> !p python table.py
xf(x)
11
28
327
464
5125
6216
7343
8512
9729
101000
(base) MAC:Wed Sep 16:09:09:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:11:interfaces> !p python table.py File "table.py", line 15 ^ SyntaxError: unexpected EOF while parsing (base) MAC:Wed Sep 16:09:11:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:11:interfaces> !p python table.py
xf(x)
11
28
327
464
5125
6216
7343
8512
9729
101000
xf(x)
11.0
21.4142135623730951
31.7320508075688772
42.0
52.23606797749979
62.449489742783178
72.6457513110645907
82.8284271247461903
93.0
103.1622776601683795
113.3166247903554
123.4641016151377544
133.605551275463989
143.7416573867739413
153.872983346207417
164.0
174.123105625617661
184.242640687119285
194.358898943540674
204.47213595499958
(base) MAC:Wed Sep 16:09:11:interfaces> !vi vi table.py (base) MAC:Wed Sep 16:09:12:interfaces> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> x = [-3, 6, -8, 0, 9, 1, -5, 2] | Error: | illegal start of expression | x = [-3, 6, -8, 0, 9, 1, -5, 2] | ^ jshell> int [] x = new int[]{-3, 6, -8, 0, 9, 1, -5, 2} x ==> int[8] { -3, 6, -8, 0, 9, 1, -5, 2 } jshell> Collections.sort(x) | Error: | no suitable method found for sort(int[]) | method java.util.Collections.sort(java.util.List) is not applicable | (cannot infer type-variable(s) T | (argument mismatch; int[] cannot be converted to java.util.List)) | method java.util.Collections.sort(java.util.List,java.util.Comparator) is not applicable | (cannot infer type-variable(s) T | (actual and formal argument lists differ in length)) | Collections.sort(x) | ^--------------^ jshell> ArrayList al = new ArrayList<>(); al ==> [] jshell> al.addAll(x); | Error: | incompatible types: int[] cannot be converted to java.util.Collection | al.addAll(x); | ^ jshell> for(int t: x){al.add(t);} jshell> x x ==> int[8] { -3, 6, -8, 0, 9, 1, -5, 2 } jshell> al al ==> [-3, 6, -8, 0, 9, 1, -5, 2] jshell> Collections.sort(al); jshell> al al ==> [-8, -5, -3, 0, 1, 2, 6, 9] jshell> Collections.sort(al, (x, y) -> x*x - y*y); jshell> al al ==> [0, 1, 2, -3, -5, 6, -8, 9] jshell>