Guide to High School Computer Science
  • 💻Introduction
    • windows & Python Development
    • macOS & Python Development
    • Visual Studio Code Settings
    • Set up Github
    • Author Page
  • 🧠Prerequisite Skills
    • Keyboard Typing
    • Files & Directories
    • Use of Command Line
    • Git & GitHub
    • Markdown
    • Starting Your Python Project
  • 🐍Python Programming
    • 🍎Python Basics
      • What is Python?
      • Procedural Programming & Programming Paradigms
      • String Formatting
      • Data Types
      • Input & Output to Console
      • Working with Numbers
      • Useful Built-in Functions
      • Math & Random Module
      • Boolean Data Object
      • Comparison, Logical, and Membership Operators
      • If Statements
      • Binary Decisions
      • Multiple Decisions
      • Nested Conditions
      • [EXTRA] Bitwise Operators
      • [EXTRA] Python Style Guide
    • ⏮️Iterations
      • Introduction to While Loops
      • Infinite Loop
      • Controlling Your While Loops
      • Introduction to For Loops
      • For Loops w/ Numeric Sequences
      • For Loops w/ Strings & Lists
      • Iterable Functions w/ For Loops
    • 📦Collections
      • Strings
        • String Basics
        • String Indexing
        • String Slicing
        • String Operators & Functions
        • Basic String Methods
        • String Methods Extended
        • String Methods Document
      • Tuples & Lists
        • Tuples
        • List Basics
        • List are Mutable
        • Adding Items to a List
        • Removing Items from a List
        • Search & Reverse a List
        • List Comprehension
        • List Methods Document
      • Sets
      • Dictionary
      • How to Store Multiple Data Items
    • 💡Defining Functions
      • Functions
      • print() vs return
      • Pre-determined Arguments
      • Nested Functions
      • Map & Filter
      • [Extra] Dynamic Arguments
    • 💾File I/O
      • How to Save Text to an External File
      • Reading CSV in Python
      • Reading JSON in Python
    • 🔨Basic Python Projects
      • Basic Calculator
        • Improving the calculator
        • Exercise Set 1
        • Exercise Set 2
        • 💎Streamlit Application #1
      • Basic Password Generator
        • Exercise Set 3
        • Exercises Related to Math
        • 💎Streamlit Application #2
      • A To-Do Task List
    • ⏳Introduction to Algorithmic Thinking
      • Big-O Notation
      • Basic Algorithms
        • Linear Search
        • Binary Search
        • Basic Sorting Algorithms
      • Recursion
      • Brute Force Algorithms
      • Greedy Algorithm
        • Time on Task (CCC 2013 J4)
        • Dijkstra’s Algorithm
      • Divide and Conquer
        • Merge Sort
      • Dynamic Programming
    • 🤯Object Oriented Programming
      • Class & Objects (Definitions)
      • OOP in Python
      • Encapsulation
      • Polymorphism
      • Inheritance & Overriding
      • Override Magic Methods
      • Case Study: 2D Vectors
      • Case Study: Deck of Cards
      • Exercise
      • Abstract Data Types
      • Case Study: Static 1D Array From Java
    • Competitive Programming
      • Is This Sum Possible?
        • Is the dataset sorted?
        • Searching for a value
        • Determine if the difference between an integer from the array and the target value exists
        • Sorting Algorithms
        • Using Two Pointers
      • Two Sum - LeetCode
        • Generate all possible pairs of values
        • Subtract each value from the target, see if the difference exists in the list
      • Longest Common Prefix - LeetCode
        • Compare all possible prefixes
        • Create the longest common prefix with the direct neighbour
      • Length of Last Word - LeetCode
        • Compare all possible prefixes
      • Where can I go from one point to another?
      • Sample Outline
    • IB Recipe Book
  • 💾Python & Databases
    • Intro to Databases & Data Modeling
      • Common Data Types in SQL
      • Introduction to ERDs
      • Primary Keys and Foreign Keys
      • Database Normalization
    • What is SQL?
      • Getting Started
      • SELECT Queries
        • Selection with Conditions
        • Selection with Fuzziness
        • Selection and Sorting in Order
        • Selection without Duplicates
        • Selection with Limited Number of Outputs
      • AGGREGATE Queries
        • Counting Rows
        • Sum, Average, Min/Max Queries
        • Working with Aggregate Queries
        • Power of using Groups
        • Exercise
      • Interacting with Multiple Table
      • Inserting Data
      • External Resource
  • ☕Java Essentials
    • Basics
      • Starting Java
      • Data & Variables
      • Handling User Inputs & Type Conversion
      • Arithmetic
      • IPO Model
      • Basic Built-in Methods
      • Exercise Questions
    • Conditionals
      • Boolean Operators
      • Compare Strings
      • If Statements
      • If Else Statements
      • Making Multiple Decisions
      • Using Switch
      • Flowchart Symbols
      • Exercise Questions
    • Iterations
      • While Loops
      • For Loop
      • Exercises
    • Java Type Casting
    • Strings
      • Common String Practices
      • String Formatting
      • Java Special Characters
    • Collection
      • Arrays
      • For Each Loop
      • ArrayList
      • Exercise Questions
    • Static Methods
      • (Aside) Clearing your Console
    • Randomness in Java
    • Delayed Output in Java
    • Java Output Formatting
    • Java Style Guide
  • 🛠️JavaScript Programming
    • Our Programming Editor & Workflow
      • Hello, world!
      • Commenting & Variables
      • Data in JavaScript
      • Operators
      • String Formatting
      • Getting User Input
    • JavaScript Exercise Set 1
    • Making Decisions
      • Comparing Values
      • Combining Boolean Comparisons
      • Creating Branches
    • JavaScript Exercise Set 2
    • While Loops
      • Infinite While Loop
      • While Loops and Numbers
      • While Loops and Flags
      • While loops w/ Strings
    • JavaScript Exercise Set 3
    • Subprograms & Functions
      • Creating a Function in JavaScript
      • Function with Input and Assignable Output
    • JavaScript Exercise Set 4
  • 💾Topics in CS
    • Computer Environments & Systems
      • Computer Components
        • In-depth Explanations
      • File Maintenance
      • Computer & Safety
      • Software Development
      • Bits & Binary
    • Careers related to Computer Science
    • Postsecondary Opportunities
Powered by GitBook
On this page
  1. Prerequisite Skills

Starting Your Python Project

PreviousMarkdownNextPython Programming

Last updated 6 months ago

0. Set Up Your Visual Studio Code

Open Visual Studio Code
File >> New Window

(In your new window)
File >> Open Folder >> Right Click on an Empty Space and Create a New Folder
     >> Select the newly created folder
  1. Learn the Terminal

  1. Create a Github Repository and Clone it onto your drive

Git + Github is a good way to do version control so that you can go back to your previous states of your program without worrying about CTRL+Z.

DO NOT CLONE A REPOSITORY INSIDE ANOTHER REPOSITORY

Creating a Public/Private GitHub Repository

  1. Log in to GitHub:

    • Go to GitHub and log in with your credentials.

  2. Create a New Repository:

    • Click on the + icon in the top right corner and select New repository.

  3. Repository Details:

    • Enter a repository name.

    • Optionally, add a description.

    • Select Public or Private under the repository visibility options.

    • Optionally, you can initialize the repository with a README, .gitignore, or a license.

  4. Create Repository:

    • Click on the Create repository button.

Cloning the Repository to Your Local Machine

  1. Copy Repository URL:

    • On your repository page, click on the Code button.

    • Copy the URL provided (HTTPS).

  2. Open Terminal/Command Prompt:

    • Open your terminal (Mac/Linux) or Command Prompt (Windows).

  3. Navigate to Desired Directory:

    • Use the cd command to navigate to the directory where you want to clone the repository.

      cd path/to/your/directory
  4. Clone the Repository:

    • Use the git clone command followed by the repository URL you copied.

      git clone https://github.com/your-username/your-repository.git
  5. Navigate into the Cloned Repository:

    • Change into the repository directory:

      cd your-repository
  1. (Windows Only) Enable your computer to run scripts

  1. Open PowerShell as Administrator:

    • Press Win + X and select Windows PowerShell (Admin) or Windows Terminal (Admin) if you're using Windows Terminal.

  2. Check Current Execution Policy:

    • In the PowerShell window, type the following command and press Enter:

    Get-ExecutionPolicy
    • This will show you the current execution policy. By default, it might be set to Restricted.

  3. Set Execution Policy:

    • To allow scripts to run, you can set the execution policy to RemoteSigned

    Set-ExecutionPolicy RemoteSigned
  1. Set up a Python Virtual Environment in your repository

The reason we want to have a Python Virtual Environment is to isolate our project for the following benefits:

  • Isolated Projects will have their own modules and libraries installed

    • Example: If your project is using an earlier version of Streamlit and your computer has a newer version of Streamlit, your project will not be affected by the local machine's version differences

  • Easier to create a list of libraries and modules your project is dependent on

Create a Virtual Environment:

// Windows
python -m venv myenv

// macOS
python3 -m venv myenv

This command creates a directory named myenv containing a new Python environment.

Activate the Virtual Environment:

On Windows:

myenv\Scripts\activate

On macOS/Linux:

source myenv/bin/activate

To Deactivate to venv you can simply run deactivate on your terminal

4a. Create a .gitignore file

With our virtual environment set up, please create a new file within the main folder of your repository not inside myenv

The file should be called .gitignore

This file will tell git to ignore the list of folders and files we write within it

Contents to be written in .gitignore

myenv/

By having this in your .gitignore, git will automatically not track changes in your virtual environment to upload to GitHub.

  1. With your virtual environment activated, Install your libraries/dependencies/modules

Windows:

python -m pip install PACKAGENAME

// Example: python -m pip install pygame

macOS:

python3 -m pip install PACKAGENAME

// Example: python3 -m pip install pygame

Now your project should have all it requires.

  1. Upload any changes to your GitHub

// On changes
git add FILENAME
git commit -m "What changes you have made"
git push

is a fanatastic tool to learn how to use the terminal.

🧠
TerminalTutor