Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ]

Type "copyright", "credits" or "license" for more information.


IPython 8.15.0 -- An enhanced Interactive Python.


Restarting kernel...


In [1]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [2]: ret = seq_sqrt([])


In [3]: ret


In [4]: print(None)

None


In [5]: seq_sqrt([])


In [6]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [7]: seq_sqrt([])

XX 1


In [8]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')

XX 1


In [9]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')

XX 1

XX 2 []


In [10]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')

XX 1

XX 2 []


In [11]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')

XX 1

XX 2 []


In [12]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [13]: seq_sqrt([])

XX 1

XX 2 []

Out[13]: []


In [14]: seq_sqrt([0, 1, 2])

XX 1

XX 2 []

XX 3

XX 3

XX 3

Out[14]: [0.0, 1.0, 1.4142135623730951]


In [15]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [16]: seq_sqrt([0, 1, 2])

XX 1

XX 2 []

XX 3, x={x}

XX 3, x={x}

XX 3, x={x}

Out[16]: [0.0, 1.0, 1.4142135623730951]


In [17]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [18]: seq_sqrt([0, 1, 2])

XX 1

XX 2 []

XX 3, x=0

XX 3, x=1

XX 3, x=2

Out[18]: [0.0, 1.0, 1.4142135623730951]


In [19]: seq_sqrt([0, 1, 2])

XX 1

XX 2 []

XX 3, x=0

XX 3, x=1

XX 3, x=2

Out[19]: [0.0, 1.0, 1.4142135623730951]


In [20]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [21]: runfile('/Users/py4cs/Desktop/lab4.py', wdir='/Users/py4cs/Desktop')


In [22]: seq_sqrt([0, 1, 2])

XX 1

XX 2 []

XX 3, x=0

Out[22]: [0.0]


In [23]: noaa_data_string = 'Southampton / Weather Centre, United Kingdom (EGHI) 50-54N 001-24W 0M\nSep 19, 2009 - 09:20 AM EDT / 2009.09.19 1320 ...0%\nPressure (altimeter): 29.97 in. Hg (1015 hPa)\nob: EGHI 191320Z 01005KT 320V050 9000 FEW040 21/13 Q1015\ncycle: 13'


In [24]: print(noaa_data_string)

Southampton / Weather Centre, United Kingdom (EGHI) 50-54N 001-24W 0M

Sep 19, 2009 - 09:20 AM EDT / 2009.09.19 1320 ...0%

Pressure (altimeter): 29.97 in. Hg (1015 hPa)

ob: EGHI 191320Z 01005KT 320V050 9000 FEW040 21/13 Q1015

cycle: 13


In [25]: data = """Southampton / Weather Centre, United Kingdom (EGHI) 50-54N 001-24W 0M

    ...: Sep 19, 2009 - 09:20 AM EDT / 2009.09.19 1320 UTC

    ...: Wind: from the N (010 degrees) at 6 MPH (5 KT) (direction variable):0

    ...: Visibility: 5 mile(s):0

    ...: Sky conditions: mostly clear

    ...: Temperature: 69 F (21 C)

    ...: Dew Point: 55 F (13 C)

    ...: Relative Humidity: 60%

    ...: Pressure (altimeter): 29.97 in. Hg (1015 hPa)

    ...: ob: EGHI 191320Z 01005KT 320V050 9000 FEW040 21/13 Q1015

    ...: cycle: 13"""


In [26]: print(data)

Southampton / Weather Centre, United Kingdom (EGHI) 50-54N 001-24W 0M

Sep 19, 2009 - 09:20 AM EDT / 2009.09.19 1320 UTC

Wind: from the N (010 degrees) at 6 MPH (5 KT) (direction variable):0

Visibility: 5 mile(s):0

Sky conditions: mostly clear

Temperature: 69 F (21 C)

Dew Point: 55 F (13 C)

Relative Humidity: 60%

Pressure (altimeter): 29.97 in. Hg (1015 hPa)

ob: EGHI 191320Z 01005KT 320V050 9000 FEW040 21/13 Q1015

cycle: 13


In [27]: runfile('/Users/py4cs/Desktop/training4.py', wdir='/Users/py4cs/Desktop')


In [28]: noaa_temperature(data)

Traceback (most recent call last):


Cell In[28], line 1

noaa_temperature(data)


File ~/Desktop/training4.py:35 in noaa_temperature

Tstr = line.split('(')[1][0:2]


IndexError: list index out of range



In [29]: line = data.split("\n")


In [30]: line = data.split("\n")[4]


In [31]: line

Out[31]: 'Sky conditions: mostly clear'


In [32]: runfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')


In [33]: runfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

60


In [34]: [10, 20, 30].pop()

Out[34]: 30


In [35]: a = [10, 20, 30]


In [36]: a.pop()

Out[36]: 30


In [37]: a

Out[37]: [10, 20]


In [38]: runfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

60


In [39]: xs

Out[39]: []


In [40]: runfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

60

xs=[]


In [41]: %reset -f


In [42]: debugfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

> /Users/py4cs/Desktop/side_effect1.py(1)<module>()

----> 1 def sum_(xs):

2 s = 0

3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !step

--Call--


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next

--Return--


IPdb [1]: !next


IPdb [1]: !next

60


IPdb [1]: !next

xs=[]

--Return--


IPdb [1]: !exit


In [43]: debugfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

> /Users/py4cs/Desktop/side_effect1.py(1)<module>()

----> 1 def sum_(xs):

2 s = 0

3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !next


IPdb [1]: !step

--Call--


IPdb [1]: !return

60--Return--


IPdb [1]: !next

--Call--


IPdb [1]: !return


--Return--


IPdb [1]: !return


IPdb [1]: !exit


In [44]: runfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

60

xs=[]


In [45]: debugfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

> /Users/py4cs/Desktop/side_effect1.py(1)<module>()

----> 1 def sum_(xs):

2 s = 0

3 for i in range(len(xs)):

1 4 s = s + xs.pop()

5 return s



IPdb [1]: !continue

> /Users/py4cs/Desktop/side_effect1.py(4)sum_()

2 s = 0

3 for i in range(len(xs)):

1---> 4 s = s + xs.pop()

5 return s

6



IPdb [2]: !next


IPdb [2]: !next


IPdb [2]: !next


IPdb [2]: !next


IPdb [2]: !next


IPdb [2]: !next


IPdb [2]: !next

--Return--


IPdb [2]: !next


IPdb [2]: exit


In [46]: debugfile('/Users/py4cs/Desktop/side_effect1.py', wdir='/Users/py4cs/Desktop')

> /Users/py4cs/Desktop/side_effect1.py(1)<module>()

----> 1 def sum_(xs):

2 s = 0

3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [1]: n

> /Users/py4cs/Desktop/side_effect1.py(8)<module>()

6

7

----> 8 xs = [10, 20, 30]

9 res = sum_(xs)

10 print(res)



IPdb [2]: n

> /Users/py4cs/Desktop/side_effect1.py(9)<module>()

7

8 xs = [10, 20, 30]

----> 9 res = sum_(xs)

10 print(res)

11 print(f"xs={xs}")



IPdb [3]: s

--Call--

> /Users/py4cs/Desktop/side_effect1.py(1)sum_()

----> 1 def sum_(xs):

2 s = 0

3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [4]: n

> /Users/py4cs/Desktop/side_effect1.py(2)sum_()

1 def sum_(xs):

----> 2 s = 0

3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [5]: n

> /Users/py4cs/Desktop/side_effect1.py(3)sum_()

1 def sum_(xs):

2 s = 0

----> 3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [6]: n

> /Users/py4cs/Desktop/side_effect1.py(4)sum_()

2 s = 0

3 for i in range(len(xs)):

----> 4 s = s + xs.pop()

5 return s

6



IPdb [7]: n

> /Users/py4cs/Desktop/side_effect1.py(3)sum_()

1 def sum_(xs):

2 s = 0

----> 3 for i in range(len(xs)):

4 s = s + xs.pop()

5 return s



IPdb [8]: p s

30


IPdb [9]: exit


In [47]: 10 / 0

Traceback (most recent call last):


Cell In[47], line 1

10 / 0


ZeroDivisionError: division by zero



In [48]: print(x)

Traceback (most recent call last):


Cell In[48], line 1

print(x)


NameError: name 'x' is not defined



In [49]: x

Traceback (most recent call last):


Cell In[49], line 1

x


NameError: name 'x' is not defined



In [50]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

Traceback (most recent call last):


File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec

exec(code, globals, locals)


File ~/Desktop/untitled14.py:4

f = open('this-file-does-not-exist', 'rt')


FileNotFoundError: [Errno 2] No such file or directory: 'this-file-does-not-exist'



In [51]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found


In [52]: sys.exit(1)

Traceback (most recent call last):


Cell In[52], line 1

sys.exit(1)


NameError: name 'sys' is not defined



In [53]: import sys


In [54]: sys.exit(1)

An exception has occurred, use %tb to see the full traceback.


SystemExit: 1


/Users/py4cs/anaconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py:3534: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.

warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)


In [55]: runfile('/Users/py4cs/Desktop/untitled15.py', wdir='/Users/py4cs/Desktop')

Program starts

An exception has occurred, use %tb to see the full traceback.


SystemExit: 1



In [56]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found

An exception has occurred, use %tb to see the full traceback.


Traceback (most recent call last):


File ~/Desktop/untitled14.py:5

f = open('this-file-does-not-exist', 'rt')


FileNotFoundError: [Errno 2] No such file or directory: 'this-file-does-not-exist'



During handling of the above exception, another exception occurred:


SystemExit: 1



In [57]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found


In [58]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found

[Errno 2] No such file or directory: 'this-file-does-not-exist'


In [59]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found

Traceback (most recent call last):


File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec

exec(code, globals, locals)


File ~/Desktop/untitled14.py:5

f = open('this-file-does-not-exist', 'rt')


FileNotFoundError: [Errno 2] No such file or directory: 'this-file-does-not-exist'



In [60]: open('this-file-does-not-exist', 'rt')

Traceback (most recent call last):


Cell In[60], line 1

open('this-file-does-not-exist', 'rt')


File ~/anaconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py:286 in _modified_open

return io_open(file, *args, **kwargs)


FileNotFoundError: [Errno 2] No such file or directory: 'this-file-does-not-exist'



In [61]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found


In [62]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found - the program has to stop


In [63]: runfile('/Users/py4cs/Desktop/untitled14.py', wdir='/Users/py4cs/Desktop')

The file could not be found - the program has to stop

Traceback (most recent call last):


File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec

exec(code, globals, locals)


File ~/Desktop/untitled14.py:5

f = open('this-file-does-not-exist', 'rt')


FileNotFoundError: [Errno 2] No such file or directory: 'this-file-does-not-exist'



In [64]: runfile('/Users/py4cs/Desktop/untitled16.py', wdir='/Users/py4cs/Desktop')


In [65]: my_complicated_function("hello world")

Traceback (most recent call last):


Cell In[65], line 1

my_complicated_function("hello world")


File ~/Desktop/untitled16.py:3 in my_complicated_function

raise NotImplementedError(message)


NotImplementedError: Called with x=hello world



In [66]: runfile('/Users/py4cs/Desktop/untitled16.py', wdir='/Users/py4cs/Desktop')


In [67]: my_complicated_function("hello world")

Traceback (most recent call last):


Cell In[67], line 1

my_complicated_function("hello world")


File ~/Desktop/untitled16.py:3 in my_complicated_function

raise NotImplementedError([message, 42])


NotImplementedError: ['Called with x=hello world', 42]



In [68]: runfile('/Users/py4cs/Desktop/print_line_sum_of_file.py', wdir='/Users/py4cs/Desktop')

380

50

17


In [69]: runfile('/Users/py4cs/Desktop/print_line_sum_of_file.py', wdir='/Users/py4cs/Desktop')

380

Traceback (most recent call last):


File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec

exec(code, globals, locals)


File ~/Desktop/print_line_sum_of_file.py:24

print_line_sum_of_file('data.txt')


File ~/Desktop/print_line_sum_of_file.py:18 in print_line_sum_of_file

number = int(term)


ValueError: invalid literal for int() with base 10: 'cat'



In [70]: runfile('/Users/py4cs/Desktop/print_line_sum_of_file.py', wdir='/Users/py4cs/Desktop')

380

5

0


In [71]: print()



In [71]:


In [72]: print("Hello")

Hello


In [73]: print(42)

42


In [74]: 42.__str__()

Cell In[74], line 1

42.__str__()

^

SyntaxError: invalid decimal literal



In [75]: a = 42


In [76]: a.__str__()

Out[76]: '42'


In [77]: str(42)

Out[77]: '42'


In [78]: print("dog", "cat", 42)

dog cat 42


In [79]: print("Dog", end='')

Dog


In [80]: print("Dog", end=''); print("Cat")

DogCat


In [81]: print("Dog", end='\n\n'); print("Cat")

Dog


Cat


In [82]: print(1); print(2)

1

2


In [83]: print(1) print(2)

Cell In[83], line 1

print(1) print(2)

^

SyntaxError: invalid syntax



In [84]: print(1)

1


In [85]: print("Dog", end=' [bark]\n'); print("Cat")

Dog [bark]

Cat


In [86]: print("Dog", end=' [bark]\n'). print("Cat")

Dog [bark]

Traceback (most recent call last):


Cell In[86], line 1

print("Dog", end=' [bark]\n'). print("Cat")


AttributeError: 'NoneType' object has no attribute 'print'



In [87]: x

Traceback (most recent call last):


Cell In[87], line 1

x


NameError: name 'x' is not defined



In [88]: x = 4


In [89]: f"the value of x is {x}"

Out[89]: 'the value of x is 4'


In [90]: print(f"the value of x is {x}")

the value of x is 4


In [91]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')


In [92]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [93]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [94]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [95]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [96]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.125

1.0 1.0

1.5 3.375

2.0 8.0

2.5 15.625


In [97]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.25

1.0 1.0

1.5 2.25

2.0 4.0

2.5 6.25


In [98]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.0

0.5 0.7071067811865476

1.0 1.0

1.5 1.224744871391589

2.0 1.4142135623730951

2.5 1.5811388300841898


In [99]: import math


In [100]: math.cos(0)

Out[100]: 1.0


In [101]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.0

0.5 0.8775825618903728

1.0 0.5403023058681398

1.5 0.0707372016677029

2.0 -0.4161468365471424

2.5 -0.8011436155469337


In [102]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000e+00

0.5 8.775826e-01

1.0 5.403023e-01

1.5 7.073720e-02

2.0 -4.161468e-01

2.5 -8.011436e-01


In [103]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 0.877583

1.0 0.540302

1.5 0.070737

2.0 -0.416147

2.5 -0.801144


In [104]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 0.877583

1.0 0.540302

1.5 0.070737

2.0 -0.416147

2.5 -0.801144


In [105]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 0.877583

1.0 0.540302

1.5 0.070737

2.0 -0.416147

2.5 -0.801144


In [106]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 0.877583

1.0 0.540302

1.5 0.070737

2.0 -0.416147

2.5 -0.801144


In [107]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.479426

1.0 0.841471

1.5 0.997495

2.0 0.909297

2.5 0.598472


In [108]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 1.648721

1.0 2.718282

1.5 4.481689

2.0 7.389056

2.5 12.182494


In [109]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 1.648721

1.0 2.718282

1.5 4.481689

2.0 7.389056

2.5 12.182494


In [110]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 1.648721

1.0 2.718282

1.5 4.481689

2.0 7.389056

2.5 12.182494


In [111]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 1.648721

1.0 2.718282

1.5 4.481689

2.0 7.389056

2.5 12.182494

3.0 20.085537

3.5 33.115452

4.0 54.598150

4.5 90.017131


In [112]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 1.000000

0.5 1.648721

1.0 2.718282

1.5 4.481689

2.0 7.389056

2.5 12.182494

3.0 20.085537

3.5 33.115452

4.0 54.598150

4.5 90.017131

5.0 148.413159


In [113]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.250000

1.0 1.000000

1.5 2.250000

2.0 4.000000

2.5 6.250000


In [114]: lambda x: x**2

Out[114]: <function __main__.<lambda>(x)>


In [115]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.250000

1.0 1.000000

1.5 2.250000

2.0 4.000000

2.5 6.250000


In [116]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.125000

1.0 1.000000

1.5 3.375000

2.0 8.000000

2.5 15.625000


In [117]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 10.000000

0.5 10.125000

1.0 11.000000

1.5 13.375000

2.0 18.000000

2.5 25.625000


In [118]: af = lambda x: x**2


In [119]: type(af)

Out[119]: function


In [120]: af

Out[120]: <function __main__.<lambda>(x)>


In [121]: af(2)

Out[121]: 4


In [122]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.250000

1.0 1.000000

1.5 2.250000

2.0 4.000000

2.5 6.250000


In [123]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.250000

1.0 1.000000

1.5 2.250000

2.0 4.000000

2.5 6.250000


In [124]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

0.0 0.000000

0.5 0.250000

1.0 1.000000

1.5 2.250000

2.0 4.000000

2.5 6.250000


In [125]: runfile('/Users/py4cs/Desktop/print_x2.py', wdir='/Users/py4cs/Desktop')

Traceback (most recent call last):


File ~/anaconda3/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec

exec(code, globals, locals)


File ~/Desktop/print_x2.py:43

print_f_table(square)


File ~/Desktop/print_x2.py:35 in print_f_table

y = f(b)


NameError: name 'b' is not defined



In [126]: