0% found this document useful (0 votes)
2 views

Introduction_to_CS___Topic_1__Python

The document provides an introduction to Python programming using Conda and Visual Studio Code. It covers installation steps for Miniconda and Visual Studio Code, as well as basic Python concepts such as variables, lists, functions, and control flow structures. Additionally, it includes commands for managing virtual environments with Conda and running Python scripts in Visual Studio Code.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction_to_CS___Topic_1__Python

The document provides an introduction to Python programming using Conda and Visual Studio Code. It covers installation steps for Miniconda and Visual Studio Code, as well as basic Python concepts such as variables, lists, functions, and control flow structures. Additionally, it includes commands for managing virtual environments with Conda and running Python scripts in Visual Studio Code.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction to Computer Science

Topic 1: Python
Pham Minh Hoang
November 29, 2022

1 Get started with Conda


1.1 Install Miniconda
Download the latest version Miniconda from here. Click the installation file to start

1.2 Conda virtual enviroment


Conda is a package and environment manager that handles the tools we use to develop ap-
plications in Python. Conda lets us easily create and manage separate virtual environments
to isolate installation of Python and its libraries, preventing these types of version conflicts.
After the successful installation, we can start with several command line commands at the
Anaconda Prompt for Windows. At first, open the Anaconda Prompt window

• Create a new virtual environment conda create -n <env name>python=<version>

1
• List all virtual environments conda env list

• Activate a virtual environment conda activate <env name>

• Deactivate a current virtual environment conda deactivate

• Remove a virtual environment conda remove −−name <env name>−−all

2
2 Get started with Visual Studio Code
Visual Studio Code is a lightweight but powerful source code editor which runs on your
desktop and is available for Windows, macOS and Linux. It comes with built-in support
for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other
languages and runtimes (such as C++, C#, Java, Python, PHP, Go, .NET).

2.1 Install Visual Studio Code


Download the latest version Visual Studio Code from here. Click the installation file to start

You can browse and install extensions from within VS Code. Extensions let you add
languages, debuggers, and tools to your installation to support your development workflow.
Installing a new extension by clicking on the Extensions icon in the Activity Bar on the left
side of VS Code or the choose menu View > Extensions To support Python programming,
you can install Python extension by open Extension, search Python, and install

2.2 Run the first Python ”Hello world”


To open a folder, click File menu, choose Open Folder

3
To create a new Python script, select the folder, click the icon New File, and rename
your file ”hello.py”

In ”hello.py”, write the below script

To open Terminal, press ”Ctrl + ∼” or choose Terminal >New Terminal To select


Command Prompt as a terminal, press ”Ctrl + Shift + P”, type ”Terminal Select Default
Profile”, choose ”Command Prompt

To run python script, type python <script-name.py>

4
3 Python programming
3.1 Variable
A variable can be declared by an assignment. Variables do not need to be declared with any
particular type, and can even change type after they have been set.

Source Code 1: Example of variable assignment

# a is assign to a integer
a = 1

# a is assigned to a string
a = " Hello ␣ world !"

# a is assigned to a list consisting of integer


a = [1 , 2, 3]

# a is assigned to a list consisting of multiple values


a = [1.2 , " Hello " , 4]

3.2 List
Lists are used to store multiple items in a single variable. More details about list can be
found here and here

3.3 Function
A function is a block of code which only runs when it is called. You can pass data, known
as parameters, into a function. A function can return data as a result. More details about
function can be found here and here

3.4 If..else
More details about if/else can be found here

5
3.5 For loop
More details about for loop can be found here

3.6 While loop


More details about while loop can be found here

References
[1] The OpenCV Tutorials

[2] The OpenCV Document page


https://docs.opencv.org/3.4/index.html

[3] OpenCV Tutorial C++


https://www.opencv-srf.com/2011/11/track-bars.html

[4] Learn OpenCV by Examples


http://opencvexamples.blogspot.com/2013/10/adding-trackbar.html

You might also like