Last login: Tue Sep 8 11:18:55 on ttys004 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:Tue Sep 08:11:28:listGames> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> int[] x = new int[10]; x ==> int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> String[] names = new String[]{"Manny", "Moe", "Jack"} names ==> String[3] { "Manny", "Moe", "Jack" } jshell> for(int k = 0; k < x.length; k++){x[k] = k*k;} jshell> x x ==> int[10] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> x[0:] | Error: | ']' expected | x[0:] | ^ jshell> Arrays.copyOfRange(x, 1) | Error: | no suitable method found for copyOfRange(int[],int) | method java.util.Arrays.copyOfRange(T[],int,int) is not applicable | (cannot infer type-variable(s) T | (actual and formal argument lists differ in length)) | method java.util.Arrays.copyOfRange(U[],int,int,java.lang.Class) is not applicable | (cannot infer type-variable(s) T,U | (actual and formal argument lists differ in length)) | Arrays.copyOfRange(x, 1) | ^----------------^ jshell> Arrays.copyOfRange(x, 1, 10) $5 ==> int[9] { 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> Arrays.copyOfRange(x, 3,5) $6 ==> int[2] { 9, 16 } jshell> x x ==> int[10] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> int[] y = Arrays.copyOf(x, 20); y ==> int[20] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> ArrayList al = al.addAll(y); | Error: | incompatible types: int[] cannot be converted to java.util.Collection | ArrayList al = al.addAll(y); | ^ jshell> ArrayList al = al.addAll(y.asList()); | Error: | cannot find symbol | symbol: method asList() | ArrayList al = al.addAll(y.asList()); | ^------^ jshell> ArrayList al = al.addAll(asList(y)); | Error: | cannot find symbol | symbol: method asList(int[]) | ArrayList al = al.addAll(asList(y)); | ^----^ jshell> ArrayList al = al.addAll(Arrays.asList(y)); | Error: | incompatible types: inference variable T has incompatible bounds | lower bounds: java.lang.Integer,java.lang.Object | lower bounds: int[] | ArrayList al = al.addAll(Arrays.asList(y)); | ^-------^ jshell> y y ==> int[20] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> ArrayList al = new ArrayList<>(); al ==> [] jshell> s | Error: | cannot find symbol | symbol: variable s | s | ^ jshell> al.addAll(names); | Error: | incompatible types: java.lang.String[] cannot be converted to java.util.Collection | al.addAll(names); | ^---^ jshell> al.addAll(Arrays.asList(names)); $11 ==> true jshell> al al ==> [Manny, Moe, Jack] jshell> #this only works for object types, not primitives | Error: | illegal character: '#' | #this only works for object types, not primitives | ^ | Error: | ';' expected | #this only works for object types, not primitives | ^ jshell> /exit | Goodbye (base) MAC:Thu Sep 10:10:33:listGames> ssh morrison@utility0 Last login: Thu Sep 10 10:28:12 2020 from 172.31.250.102 SERVER:Thu Sep 10:10:33:~> B SERVER:Thu Sep 10:10:33:4240> cd Sep/10Sep20/ SERVER:Thu Sep 10:10:33:10Sep20> ls index.php tree.py SERVER:Thu Sep 10:10:33:10Sep20> python tree.py * ** *** **** ***** * ** *** **** ***** SERVER:Thu Sep 10:10:33:10Sep20> !vi vi index.php SERVER:Thu Sep 10:10:33:10Sep20> python tree.py * ** *** **** ***** * ** *** **** ***** * ** *** **** ***** SERVER:Thu Sep 10:10:34:10Sep20> !vi vi index.php SERVER:Thu Sep 10:10:34:10Sep20> python xmasTree.py * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * SERVER:Thu Sep 10:10:52:10Sep20> !vi vi index.php SERVER:Thu Sep 10:10:52:10Sep20> python funcEx.py SERVER:Thu Sep 10:11:09:10Sep20> !vi vi index.php SERVER:Thu Sep 10:11:09:10Sep20> python funcEx.py File "funcEx.py", line 5 print(f"square{x} = {square(x)}") ^ SyntaxError: invalid syntax SERVER:Thu Sep 10:11:11:10Sep20> exit logout Connection to utility0 closed. (base) MAC:Thu Sep 10:11:11:listGames> B (base) MAC:Thu Sep 10:11:11:4240> ls convert lab1 names.txt roster.txt students week2 keethan.txt listGames roster.csv stringPlay vpn.txt (base) MAC:Thu Sep 10:11:11:4240> mkdir functions (base) MAC:Thu Sep 10:11:11:4240> cd functions/ (base) MAC:Thu Sep 10:11:11:functions> vi funcEx.py (base) MAC:Thu Sep 10:11:22:functions> python funcEx.py square(10) = 100 cube(10) = 1000 (base) MAC:Thu Sep 10:11:22:functions> !vi vi funcEx.py (base) MAC:Thu Sep 10:11:25:functions> time python funcEx.py square(10) = 100 cube(10) = 1000 real 0m0.163s user 0m0.054s sys 0m0.037s (base) MAC:Thu Sep 10:11:25:functions> !vi vi funcEx.py (base) MAC:Thu Sep 10:11:28:functions> !p python funcEx.py File "funcEx.py", line 13 ^ SyntaxError: unexpected EOF while parsing (base) MAC:Thu Sep 10:11:28:functions> !vi vi funcEx.py (base) MAC:Thu Sep 10:11:28:functions> !p python funcEx.py square(10) = 100 cube(10) = 1000 Traceback (most recent call last): File "funcEx.py", line 12, in print(lawOfCosines(3,4, math.PI/2)) AttributeError: module 'math' has no attribute 'PI' (base) MAC:Thu Sep 10:11:28:functions> !vi vi funcEx.py (base) MAC:Thu Sep 10:11:29:functions> !p python funcEx.py square(10) = 100 cube(10) = 1000 5.0 (base) MAC:Thu Sep 10:11:29:functions> !vi vi funcEx.py (base) MAC:Thu Sep 10:11:29:functions> 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. >>> import math >>> dir(math) ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc'] >>> help(math.sin) >>> help(math.floor) >>> print(math.floor.__doc__) Return the floor of x as an Integral. This is the largest integer <= x. >>> math.pi = 3 >>> math.pi 3 >>> (base) MAC:Thu Sep 10:11:31:functions> !p 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. >>> import math >>> math.pi 3.141592653589793 >>> (base) MAC:Thu Sep 10:11:32:functions> vi tryThis.py (base) MAC:Thu Sep 10:11:33:functions> 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. >>> pow(2,5) 32 >>> type(pow(2,5)) >>> import maht Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'maht' >>> import math >>> math.pow(4,5) 1024.0 >>> pow4,5) File "", line 1 pow4,5) ^ SyntaxError: invalid syntax >>> pow(4,5) 1024 >>> 2**.5 1.4142135623730951 >>> 2**(1/3) 1.2599210498948732 >>> >>> pow(2,1.5) 2.8284271247461903 >>> pow(2,-3) 0.125 >>> pow(10,-3) 0.001 >>> 10**(-3) 0.001 >>> (base) MAC:Thu Sep 10:11:36:functions> vi tryThis.py (base) MAC:Thu Sep 10:11:39:functions> python tryThis.py FAIL FAIL (base) MAC:Thu Sep 10:11:39:functions> !vi vi tryThis.py (base) MAC:Thu Sep 10:11:42:functions> python tryThis.py PASS PASS (base) MAC:Thu Sep 10:11:42:functions> !vi vi tryThis.py (base) MAC:Thu Sep 10:11:44:functions> !p python tryThis.py PASS PASS 32.0 -40.0 212.0 (base) MAC:Thu Sep 10:11:44:functions> !vi vi tryThis.py (base) MAC:Thu Sep 10:11:46:functions> !p python tryThis.py PASS PASS 32.0 -40.0 212.0 None None None (base) MAC:Thu Sep 10:11:46:functions> !vi vi tryThis.py (base) MAC:Thu Sep 10:11:48:functions> python tryThis.py PASS PASS 32.0 -40.0 212.0 0.0 -40.0 100.0 (base) MAC:Thu Sep 10:11:48:functions> !vi vi tryThis.py (base) MAC:Thu Sep 10:12:25:functions> ls funcEx.py tryThis.py (base) MAC:Thu Sep 10:12:25:functions>