I installed Anaconda 3 and VSCode on Win 10 and optimistically following a beginners course called 'Learn Python in One Day and Learn It Well.' Well I had to start somewhere!
I am trying to run one of the demo programs setting up a class as part of my beginners course. I wanted to use VSCode which was recommended but I don't understand exactly what is happening with the terminal window.
The exercise involves setting up a class and then entering an instruction which returns the name value of the instance(?). The demo code is:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 14 23:07:39 2021
@author: Jon
"""
# democlass
class Staff:
def __init__ (self,pPosition,pName,pPay):
self.position = pPosition
self.name = pName
self.pay = pPay
print('Creating Staff object' )
def __str__(self):
return "Position = %s, Name = %s, Pay = %d" %(self.position, self.name, self.pay)
def calculatePay(self):
prompt = '\nEnter number of hours worked for %s: ' %(self.name)
hours = input(prompt)
prompt = 'Enter the hourly rate for %s: ' %(self.name)
officeStaff1 = Staff('Basic' , 'Yvonne' , 0)
When I run the file in Terminal(VSCode) the program seems to complete properly, then the next course instruction says:
Try adding the following lines to Shell and see what happens- officeStaff1.name
I am not sure what Shell means as far as VSCode is concerned but if i enter this command in the Terminal it generates an error due to not recognising the command as the name of a cmdlet.
Anaconda also installed Spyder if I run the same code in Spyder and follow the instructions and type:
officeStaff1.name at the console prompt I get the correct answer - 'Yvonne'
I assume that I am either using the wrong VSCode terminal or I have not set up the terminal correctly but I simply cannot work out what I need to do. I think I have the path and the environment set correctly but to be honest the jargon is completely throwing me. I just cannot figure out what I am doing wrong in VSCode.