Hello, Operator! Allow me to personally welcome you to your new job at Transcom! We have the trusted responsibility of making sure that messages go from the SENDER to the intended RECIPIENT. Lucky for us, it's super simple to do so! Just drag the SENDER plug to the hole next to the green light. Provided to YouTube by The Orchard EnterprisesHello Operator (Classic 12' Version) Was (Not Was)(The Woodwork) Squeaks℗ 2004 ZE RecordsReleased on: 2004-01. Hello Operator lyrics, Hello Operator discography sorted by album. The Mac is a fun and powerful platform, and Objective-C is a wonderful language for writing code. You can have a great time programming the Mac in Objective-C. We do, and want you to join us! Mark Dalrymple is a longtime Mac and Unix programmer who has code running all over the world. Scott Knaster is a legendary Mac programmer and author of.
GoLang is a compiled programming language, developed and designed at Google in 2007. Its syntax is similar to that of C programming language. Writing a Go program is really easy as we will see. Today we will write our first Go program.
Select the required files in the Finder. Right-click and select Compress 5 Items. Rename the resulting file to hello.zip. Select the required files in Windows Explorer. Right-click and select Send to - Compressed (zipped) folder. Rename the resulting file to hello.
1. Setting up Go workspace
An organized file structure is really important when programming in GoLang. This is done by keeping all Go source in one main directory. That directory is known as the workspace.
In windows that directory is %USERPROFILE%/Go. In Unix based systems it is set to $HOME/Go.
You can change your workspace by changing the GOPATH.
A workspace can contain multiple version-controlled repositories. These repositories can contain several packages. A package contains Go source files.
That path of the package directory is its import path.
1.1) Our workspace setup
Since our workspace directory is created already, we only need to have three subdirectories inside it. If yours have already set up, you can skip this.
Just create three subdirectories as shown below:
As you can see above there are three subdirectories, bin, pkg, and src.
1.2) Workspace hierarchy
The foldersrc will contain all source files and the bin folder will contain the binaries or the executable commands. The pkg directory will contain installed packages.
Above is a sample directory structure for Go workspace.
So, let's create our own package inside which our first source file will be.
2. Hello World Go program
So, let's create our first Go program and execute it.
2.1) Creating our first package
Just create a directory inside src/. It will be our first package. Let's call it go-project.
2.2) Writing our first Go code
Create a file inside that folder (in our case, go-project) and call it main.go. You can call it anything.
Now, write the code in that file. Don't worry if you don't understand it right now.
Notice that you don't need semicolons!
2.3) Explanation of the code
Here package main is defined above which means the program will run inside the main package.
Then in the next line, we imported a very useful package fmt using the import statement. The way to import file is:
After importing we created a function called main. The main function is the function that runs at the start. The declaration of a function is really simple, we need to use the func keyword.
Inside the main function, we included:
It means we are using the Println function of fmt package to print 'Hello World' in the console.
Hello Operator. Mac Os Catalina
2.4) Building Go Hello World Program
Now let's build that. In order to build it, we will use the go tool. Anotimps mac os. It is a command-line tool that comes with GoLang.
We need to use the command go build
inside that project directory.
Now we will see that an executable has been created. The name of the executable will be its repository name. In our case go-project.exe.
Now, let's execute it and see what happens. To execute that, we simply run ./filename.exe, in our case ./go-project.exe.
It works! Our program just printed 'Hello World!' on the console. Congratulations on writing your first Go program.
This page tells you how to setup a Python programming environment for your Mac OS X computer and provides a step-by-step guide for creating and running a simple 'Hello, world' Python program. All of the software is freely available on the Web. These instructions are for MacOS X 10.13 (High Sierra), but the instructions for other versions of Mac OS X are similar.
Overview
The Python programming environment required by this booksite consists of:
- Python, that is, the Python compiler/interpreter.
- The Python standard libraries.
- IDLE, the Python Integrated DeveLopment Environment.
- The Tkinter, NumPy, and Pygame libraries, which are used by the booksite programs that do graphics or audio processing.
- The booksite library, that is, a set of modules that we developed specifically to support this booksite.
- The Terminal application that is bundled with Mac OS X.
Downloading and Installing Python, IDLE, Tkinter, NumPy, and Pygame
A version of Python 2 is bundled with Mac OS X. It's fine to use that version. IDLE, Tkinter, and NumPy are part of that version, but you must download and install Pygame yourself.
Perform these steps to download and install Pygame:
Open a Terminal window. To do that, click on the Spotlight Search icon on the right end of the menu bar. (It has the appearance of a magnifying glass.) In the resulting dialog box, type
Terminal.app
followed by the Enter key.In the Terminal window issue these commands to install pip, the Python package manager. Enter your computer's administrator password when prompted:
In the Terminal window issue this command to use pip to install Pygame:
Perform these steps to test your environment:
In the Terminal window issue the
python
command. You should see something like this:If you see that output, then your Python compiler/interpreter is working, and Tkinter, numpy, and IDLE are available.
At the Python
>>>
prompt, type the statementimport pygame
followed by the Enter key. If Python generates no error messages, then you have installed Pygame properly.At the Python
>>>
prompt, typeexit()
followed by the Enter key to exit Python.Close the Terminal window.
Downloading and Installing the Booksite Library
Perform these steps to download and install the booksite library:
Use your Web browser to download this introcs-1.0.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double click on the
/Users/yourusername/Downloads/introcs-1.0.zip
file to unzip the file, thus creating a directory named/Users/yourusername/Downloads/introcs-1.0
.Open a Terminal window.
At any time the Terminal application has a working directory. Initially the working directory is
/Users/yourusername
. In the Terminal window issue thecd Downloads
command to change your working directory to/Users/yourusername/Downloads
, and then issue thecd introcs-1.0
command to change your working directory to/Users/yourusername/Downloads/introcs-1.0
. (Incidentally, thecd .
command changes your working directory to the 'parent' of the current working directory.)Issue the
ls
command to display the names of all files in your working directory. Make sure that a file namedsetup.py
is in your working directory.Issue the
python setup.py install --user
command. The computer copies the files defining the booksite modules to a directory where Python can find them, and writes status messages to your Terminal window to indicate its progress.
Note: The Mac Finder application uses the term folder to mean a container of documents and, perhaps, other folders. This document instead uses the equivalent Unix term directory. |
Perform these steps to test your installation of the booksite library:
In the Terminal window issue the
python
command.At the Python
>>>
prompt, type the statementimport stdio
followed by the Enter key. If Python generates no error messages, then you have installed the booksite library properly.At the Python
>>>
prompt, typeexit()
followed by the Enter key to exit Python.Close the Terminal window.
Mac Os Versions
Configuring IDLE
So far you've downloaded and installed all of the software that you'll need. You should perform one more step before creating your first program: configure the IDLE programming environment. Follow these instructions:
Open a Terminal window.
In the Terminal window issue the command
idle
to launch IDLE.Click on the Python → Preferences.. menu item.
Click on the General tab.
Click on the Open Edit Window radio button.
Click on the Ok button.
Close the IDLE window.
Close the Terminal window.
Composing Your First Program
Having installed Python, the Python standard libraries, IDLE, Tkinter, NumPy, Pygame, and the booksite libraries, and having configured IDLE, you are ready to compose your first Python program. Perform these instructions:
Using the Finder, create a directory named
/Users/yourusername/hello
.Open a Terminal window.
Issue the
cd hello
command to make the/Users/yourusername/hello
directory your working directory.Issue the command
idle &
to launch IDLE. Note the trailing ampersand. The trailing ampersand tells the computer to run theidleX
program in the background, thereby leaving your Terminal application free to handle additional commands while IDLE is running.In IDLE, type the four-line Python program helloworld.py exactly as it appears below. Use the arrow keys, mouse, or touchpad to move within the text that you have typed. Use the Delete key to delete text. Be careful; the smallest typing mistake might cause the program to fail.
When you are finished typing, in IDLE click on the File → Save.. menu item to save the Python program. Save it in a file named
helloworld.py
in the directory/Users/yourusername/hello
. The file name is case sensitive, so make sure you use all lowercase letters.
Running Your First Program
The final step is to run your program. It is possible to run some Python programs from within IDLE, but you should run the programs associated with this booksite directly from a Terminal window. To do that, perform these steps:
Within the same Terminal window, issue the
ls
command to display the names of all files in the working directory. Confirm that the working directory contains yourhelloworld.py
file.Issue the
python helloworld.py
command to run your program. If the computer writes 'Hello, World' to the Terminal window, then the execution of yourhelloworld.py
program was successful. If the computer instead writes error messages, then use IDLE to correct your program, and issue thepython helloworld.py
command again. Repeat until your program runs successfully. If your program runs successfully the first time you try, then intentionally introduce an error into your program, just so you get some experience with correcting errors.Close the IDLE window.
Close the Terminal window.
Hello Operator. Mac Os 11
You now have installed and configured a reasonable Python environment, and have used it to compose and run a Python program. Congratulations! You are a Python programmer!
Downloading the Booksite Example Programs (optional)
We recommend that you download the booksite example programs, that is, the example Python programs that are presented incrementally throughout the booksite. Having done so, you can run those programs to help you learn about them. Perform these instructions:
Use your Web browser to download this introcs-python.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double-click on the
/Users/yourusername/Downloads/introcs-python.zip
file, thus creating the/Users/yourusername/Downloads/introcs-python
directory containing the booksite example programs. (It's OK to delete the/Users/yourusername/Downloads/introcs-python.zip
file after you have unzipped it.)
Then perform these steps to test your download of the booksite example programs:
Open a Terminal window.
Issue the
cd Downloads
andcd introcs-python
commands to make/Users/yourusername/Downloads/introcs-python
your working directory.Issue the
ls
command. Confirm that the working directory contains a file namedbouncingball.py
.Issue the
python bouncingball.py
command. If Python launches a stddraw window showing an animated bouncing ball, then your download of the booksite example programs was successful.Close the stddraw window.
Close the Terminal window.
Hello Operator. Mac Os 11
Downloading the Booksite Example Data (optional)
We recommend that you download the booksite example data, that is, the data files used by the booksite example programs that are presented incrementally throughout the booksite. Perform these instructions:
Use your Web browser to download this introcs-data.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double-click on the
/Users/yourusername/Downloads/introcs-data.zip
file, thus creating the/Users/yourusername/Downloads/introcs-data
directory containing the booksite example data files. (It's OK to delete the/Users/yourusername/Downloads/introcs-data.zip
file after you have unzipped it.)
Downloading and Installing Python, IDLE, Tkinter, NumPy, and Pygame
A version of Python 2 is bundled with Mac OS X. It's fine to use that version. IDLE, Tkinter, and NumPy are part of that version, but you must download and install Pygame yourself.
Perform these steps to download and install Pygame:
Open a Terminal window. To do that, click on the Spotlight Search icon on the right end of the menu bar. (It has the appearance of a magnifying glass.) In the resulting dialog box, type
Terminal.app
followed by the Enter key.In the Terminal window issue these commands to install pip, the Python package manager. Enter your computer's administrator password when prompted:
In the Terminal window issue this command to use pip to install Pygame:
Perform these steps to test your environment:
In the Terminal window issue the
python
command. You should see something like this:If you see that output, then your Python compiler/interpreter is working, and Tkinter, numpy, and IDLE are available.
At the Python
>>>
prompt, type the statementimport pygame
followed by the Enter key. If Python generates no error messages, then you have installed Pygame properly.At the Python
>>>
prompt, typeexit()
followed by the Enter key to exit Python.Close the Terminal window.
Downloading and Installing the Booksite Library
Perform these steps to download and install the booksite library:
Use your Web browser to download this introcs-1.0.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double click on the
/Users/yourusername/Downloads/introcs-1.0.zip
file to unzip the file, thus creating a directory named/Users/yourusername/Downloads/introcs-1.0
.Open a Terminal window.
At any time the Terminal application has a working directory. Initially the working directory is
/Users/yourusername
. In the Terminal window issue thecd Downloads
command to change your working directory to/Users/yourusername/Downloads
, and then issue thecd introcs-1.0
command to change your working directory to/Users/yourusername/Downloads/introcs-1.0
. (Incidentally, thecd .
command changes your working directory to the 'parent' of the current working directory.)Issue the
ls
command to display the names of all files in your working directory. Make sure that a file namedsetup.py
is in your working directory.Issue the
python setup.py install --user
command. The computer copies the files defining the booksite modules to a directory where Python can find them, and writes status messages to your Terminal window to indicate its progress.
Note: The Mac Finder application uses the term folder to mean a container of documents and, perhaps, other folders. This document instead uses the equivalent Unix term directory. |
Perform these steps to test your installation of the booksite library:
In the Terminal window issue the
python
command.At the Python
>>>
prompt, type the statementimport stdio
followed by the Enter key. If Python generates no error messages, then you have installed the booksite library properly.At the Python
>>>
prompt, typeexit()
followed by the Enter key to exit Python.Close the Terminal window.
Mac Os Versions
Configuring IDLE
So far you've downloaded and installed all of the software that you'll need. You should perform one more step before creating your first program: configure the IDLE programming environment. Follow these instructions:
Open a Terminal window.
In the Terminal window issue the command
idle
to launch IDLE.Click on the Python → Preferences.. menu item.
Click on the General tab.
Click on the Open Edit Window radio button.
Click on the Ok button.
Close the IDLE window.
Close the Terminal window.
Composing Your First Program
Having installed Python, the Python standard libraries, IDLE, Tkinter, NumPy, Pygame, and the booksite libraries, and having configured IDLE, you are ready to compose your first Python program. Perform these instructions:
Using the Finder, create a directory named
/Users/yourusername/hello
.Open a Terminal window.
Issue the
cd hello
command to make the/Users/yourusername/hello
directory your working directory.Issue the command
idle &
to launch IDLE. Note the trailing ampersand. The trailing ampersand tells the computer to run theidleX
program in the background, thereby leaving your Terminal application free to handle additional commands while IDLE is running.In IDLE, type the four-line Python program helloworld.py exactly as it appears below. Use the arrow keys, mouse, or touchpad to move within the text that you have typed. Use the Delete key to delete text. Be careful; the smallest typing mistake might cause the program to fail.
When you are finished typing, in IDLE click on the File → Save.. menu item to save the Python program. Save it in a file named
helloworld.py
in the directory/Users/yourusername/hello
. The file name is case sensitive, so make sure you use all lowercase letters.
Running Your First Program
The final step is to run your program. It is possible to run some Python programs from within IDLE, but you should run the programs associated with this booksite directly from a Terminal window. To do that, perform these steps:
Within the same Terminal window, issue the
ls
command to display the names of all files in the working directory. Confirm that the working directory contains yourhelloworld.py
file.Issue the
python helloworld.py
command to run your program. If the computer writes 'Hello, World' to the Terminal window, then the execution of yourhelloworld.py
program was successful. If the computer instead writes error messages, then use IDLE to correct your program, and issue thepython helloworld.py
command again. Repeat until your program runs successfully. If your program runs successfully the first time you try, then intentionally introduce an error into your program, just so you get some experience with correcting errors.Close the IDLE window.
Close the Terminal window.
Hello Operator. Mac Os 11
You now have installed and configured a reasonable Python environment, and have used it to compose and run a Python program. Congratulations! You are a Python programmer!
Downloading the Booksite Example Programs (optional)
We recommend that you download the booksite example programs, that is, the example Python programs that are presented incrementally throughout the booksite. Having done so, you can run those programs to help you learn about them. Perform these instructions:
Use your Web browser to download this introcs-python.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double-click on the
/Users/yourusername/Downloads/introcs-python.zip
file, thus creating the/Users/yourusername/Downloads/introcs-python
directory containing the booksite example programs. (It's OK to delete the/Users/yourusername/Downloads/introcs-python.zip
file after you have unzipped it.)
Then perform these steps to test your download of the booksite example programs:
Open a Terminal window.
Issue the
cd Downloads
andcd introcs-python
commands to make/Users/yourusername/Downloads/introcs-python
your working directory.Issue the
ls
command. Confirm that the working directory contains a file namedbouncingball.py
.Issue the
python bouncingball.py
command. If Python launches a stddraw window showing an animated bouncing ball, then your download of the booksite example programs was successful.Close the stddraw window.
Close the Terminal window.
Hello Operator. Mac Os 11
Downloading the Booksite Example Data (optional)
We recommend that you download the booksite example data, that is, the data files used by the booksite example programs that are presented incrementally throughout the booksite. Perform these instructions:
Use your Web browser to download this introcs-data.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double-click on the
/Users/yourusername/Downloads/introcs-data.zip
file, thus creating the/Users/yourusername/Downloads/introcs-data
directory containing the booksite example data files. (It's OK to delete the/Users/yourusername/Downloads/introcs-data.zip
file after you have unzipped it.)
Downloading the Booksite Library: Part 2 (optional)
Previously on this page we described how to download and install the booksite library so Python can find it. Now we describe how to download the booksite library so you can find it — for the sake of studying the code that implements it, should you so desire. Perform these instructions:
Use your Web browser to download this stdlib-python.zip file to your
/Users/yourusername/Downloads
directory.In the Finder, double-click on the
/Users/yourusername/Downloads/stdlib-python.zip
file, thus creating the/Users/yourusername/Downloads/stdlib-python
directory containing the booksite library. (It's OK to delete the/Users/yourusername/Downloads/stdlib-python.zip
file after you have unzipped it.)
We invite you to study the code that implements the booksite library. But don't be concerned if some of the code is cryptic. The code that implements the booksite library uses some features of Python that are beyond the scope of the textbook and this booksite.
Q & A
Q. Why do I get the error ImportError: No module named stddraw
when I issue the command python program_that_uses_stddraw.py
?
A. You must issue the command python2.7 program_that_uses_stddraw.py
, as described above.
Q. I downloaded files using my browser, but can't find them. Where are they?
A. Many browsers by default place downloaded files in the directory /Users/yourusername/Downloads
.
Q. How do I break out of an infinite loop when running my program from the Terminal application?
A. Type Ctrl-c. That is, while pressing the Ctrl key, type the c key.
Q. Must I use IDLE to create my Python programs? Can I use some other text editor?
A. You need not use IDLE to create your Python programs; it is fine to use some other text editor. For example, it is reasonable to use the TextEdit editor that is bundled with Mac OS X. However if you do use some other text editor, then make sure you change its settings so it (1) uses a four-space indentation scheme, and (2) indents using spaces instead of tabs. The Wikipedia Comparison of text editors page provides summary descriptions of many text editors.