0% found this document useful (0 votes)
34 views6 pages

Python Programming Basics for Beginners

Uploaded by

8fxkpvgqkn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views6 pages

Python Programming Basics for Beginners

Uploaded by

8fxkpvgqkn
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lecture 1: Introduction – Basic Programming in Python

Class Goals

1. Set up ability to understand more advanced cybersecurity topics


 There is a limit to the discussions we can have about cyber security without least
some knowledge of programming.
2. Set you up for greater success in industry/academia
3. Be able to have semi-technical discussions
4. Teach you something is actually useful to you now

Potential Uses

 Automation
 Data collection and processing
 Money
 Animation
 Gaming
 Machine Learning  Python is the language for this

Programming as a skill

1. Breaking down the problem (30% of the skill)

 Taking the larger problem, and figuring out the individual steps
 You should already have an idea of how to do this
 Example: writing an essay

 Start

2. Translating steps/tasks to instructions (60% of the skill)

 Taking the steps you found when breaking down the problem, and

3. Writing the syntax/keywords (10% of the skill)

 Language specific
 Fairly straightforward if you did the previous two steps

 It’s really important to learn to break down problems and translate them for
computers.

Biggest pitfalls
1. Treating code like an academic axercise

 Learning how to swim by reading a book

2. Only focusing on writing code,and not on the problem solving

 Actually writing syntax/keywords is very easy


 Breaking down the problem to figure out steps is much harder

3. Coding too late

 The longer you wait, the harder it is to catch up

4. Not coding in class

 You’ll gain little by writing notes

5. Coding in class by copying everything exactly

 <…>

Language

<…>

High-level

 Assembly language
 Hardware
 Machine Language
 High Level Language

Interpreted

 Compiled Language  run the code through compiler and make it executable which
takes more time but runs faster

 Interpreted Language  This is Python, start from the code and run it
straightforward, there is no compiler. It runs everything up until an error.

General-purpose

 Domain-specific Languages

 HTML
 SQL
 General-purpose Languages  This is Python

Object-oriented

 Has the concept of “Objects”


 We will cover this topic in great detail over two lectures

Integrated Development Environment (IDE)

 Pycharm is an IDE

Keywords

- Specific words that have set meaning

 Most programming languages have them

Syntax

 Defines the structure of the language


 Where most general-purpose languages will differ
 Python has significant spacing

 Tabs mean something in Python, in most languages they don’t.

 Python also uses colons

 <…>

What did we learn from the activity?

 Specificity is important
 Little mistakes can make a big difference
 Abstraction is useful

 Allows you to focus on the bigger picture, not on the little things.

 Computers follow instructions

 If a computer isn’t doing what you want it to do – it’s because you told it to do
the wrong thing!

 Breaking down the problem is much harder than writing the actual instructions

Lecture 2:
Float

- Decimal values

- 5.0 for example is a float

Integer

 d

String

- “5.0” for example is a string

 Holds text

Boolean

 True/False Value
 Examples:

 True
 False

Lecture 3: Control Flow + Input and Parsing


Comments in Python

 Comments are code that doesn’t run

 # Your comment here

- Just to take notes

Input()

 Taking input from the user is easy


 VariableName = input()
 What will it return?  it will return what the user types in the console

 This is an argument. The function takes this as input

 Returns a string with whatever the user enters

 Either save it in a variable

 Or use it as an argument for another function

Conditions

Comparisons
 ==
 >
 <
 
 >==

Booleans

Lecture 4: Loops
d

Common questions

Powered by AI

The course suggests a clear difference between learning programming as an academic exercise and as a practical skill. Programming prowess is not just about understanding syntax theoretically; rather, it emerges from practical problem-solving and application. This experiential learning is akin to learning to swim by immersing in water rather than reading about it, emphasizing action over theoretical knowledge .

The course outline emphasizes that breaking down problems is a fundamental skill constituting 30% of programming expertise, while translating these steps into instructions occupies 60%. This highlights that understanding problem-solving is significantly more challenging than merely writing syntax, which comprises 10% of the skill. In the context of cybersecurity, having a strong grasp of problem-solving is crucial because discussing advanced topics in cybersecurity requires foundational programming knowledge .

Abstraction in Python allows programmers to focus on larger problems by ignoring the underlying complexity, facilitating problem decomposition and modular code development. This concept is crucial in managing complex coding tasks, especially in cybersecurity, where handling intricate systems and large datasets is common. By utilizing abstraction, programmers can create reusable components, significantly enhancing efficiency and reduce potential errors .

Control flow elements like loops and conditions enable Python to execute repetitive tasks and make decisions based on variable states, respectively. Loops allow iterating over collections or performing repeated actions, essential for tasks like automation and data processing. Conditions facilitate branching logic, making Python capable of adapting to dynamic requirements in real-world applications, such as responding to user inputs or processing different data payloads .

PyCharm, as a Python IDE, enhances learning and productivity by providing a user-friendly interface with tools like syntax highlighting, code suggestions, and debugging features, which streamline the coding process and reduce common errors. It aids learners by offering an integrated environment where they can write, test, and debug Python code seamlessly, thus focusing more on understanding concepts rather than tackling setup or configuration issues .

As an interpreted language, Python runs code directly from source line-by-line rather than converting it into machine code in advance like compiled languages. This means Python executes up to an error when it encounters one, allowing for easier debugging as compared to compiled languages that execute code only after the entire codebase is compiled to an executable form .

Python is versatile and finds uses in automation, data collection and processing, financial operations, animation, gaming, and importantly, in machine learning. It is favored in machine learning due to its general-purpose nature, simpler syntax, and the extensive libraries and frameworks that facilitate machine learning tasks .

Python’s ability to take user input via the input() function and return it as a string allows developers to easily gather and manipulate text-based data from users. This string return format is versatile for processing as it can be easily converted to other data types or used directly in applications. This capability is crucial for interactive applications, enabling dynamic responses based on user commands or queries .

Python’s significant spacing enforces indentation as part of its syntax, enhancing code readability by organizing the code structure clearly, which reduces cognitive load. The use of colons to designate code blocks further emphasizes structured programming, reducing syntax errors related to block definitions common in languages that rely solely on curly braces or keywords for similar purposes .

Engaging in actual coding activities in class is crucial for active learning, allowing students to apply theoretical concepts in practical scenarios immediately. This hands-on approach ensures that students internalize problem-solving techniques and technical skills, which are more challenging to grasp through passive note-taking alone. Active coding also helps in identifying difficulties in real-time, enhancing learning retention and reinforcing understanding .

You might also like