Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Week 2 CornellNotesTemplate On Python

Week 2 CornellNotesTemplate on Python

Uploaded by

laurajackson433
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Week 2 CornellNotesTemplate On Python

Week 2 CornellNotesTemplate on Python

Uploaded by

laurajackson433
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Week: Week 2________________Name: __Theophilus_Amaye_________

Assignment: Required Reading: Programming Basic Class:CS105_Section 03P


Page 1 of 6 Date: _Due Nov 11, 2023___________ __

Instructions: You must read the material and create an outline of the topics in your OWN words. Do not copy
the text from the tutorials into your notes. Make sure your outline contains notes for each subsection of the
reading assignment. Thoroughly cover each topic to show you have a firm understanding of the programming
concept or construct.

Ques NOTES:

What is a programming A programming language is a tool that serves as a bridge to


language? enforce instructions from experts and a computer. Unlike 0s and
1s that computer use in thinking, a programming language is a bit
readable and understandable by humans and computer alike.

High Level Vs Low Level Low level programming language are languages that offer more
Programming Language granular control over computer’s resources, but they are written
very similar to binary form. This makes them less portable and
more difficult to understand.

High level programming languages on the other hand, are more


similar to human language than binary language. This means
anyone can easily understand English words like “RUN”,
“OBJECT”, “PRINT”, etc. in a code.

Most Popular The most popular programming languages include;


Programming Languages Python: Python, a versatile and general-purpose programming
language, finds utility across diverse domains, spanning data
science, machine learning, web development, and is highly
recommended as a starting language.

Java: Java, another beginner-friendly language, serves multiple


purposes, including mobile app development, software
engineering, and powering comprehensive systems. It is notably
the language used in AP Computer Science courses.

JavaScript: JavaScript, an adaptable language, facilitates both


front-end and back-end development, enabling web applications,
game creation, and mobile app development.

C#: C#, Microsoft's widely adopted programming language, suits a


wide spectrum of applications, from game development to
Week: Week 2________________Name: __Theophilus_Amaye_________
Assignment: Required Reading: Programming Basic Class:CS105_Section 03P
Page 2 of 6 Date: _Due Nov 11, 2023___________ __

Ques NOTES:
enterprise software, video games, and mobile apps.

C++: C++, renowned for its power, finds application in various


industries, including virtual reality, software and game
development, robotics, and scientific computing.

PHP: PHP, a prevalent server-side language, excels in building


dynamic web applications, seamlessly integrating with databases
and HTML.

R: R, a statistical programming language, enjoys popularity


among data scientists for analyzing data, crafting data
visualizations, and answering questions through data analysis.

Swift: Swift, Apple's language of choice, is indispensable for those


venturing into iOS and MacOS application development.

Kotlin: Kotlin, an open-source language from JetBrains, shines in


web development, Android app development, and more, making it
a versatile choice for various projects.

Some Notable Features  .Python programming code is easy to understand


of Python  It is easy to use, making possible to work others teams on
a project.
 Python has a large library that supports major programming
tasks like connecting to web servers, reading and
modifying files, etc.
 Python has IDLE (Integrated Development and Learning
Environment) that makes coding easy with feature like
auto-completion, code highlighting, etc. Python also
provides an interactive mode to test pieces of code
snippets.
 Python can be embedded into an application.
 Python can run on any platform.
 Python is free and open-source

 Python has diverse data types like numbers (such as


Programming
Week: Week 2________________Name: __Theophilus_Amaye_________
Assignment: Required Reading: Programming Basic Class:CS105_Section 03P
Page 3 of 6 Date: _Due Nov 11, 2023___________ __

Ques NOTES:
Language Features of floating point, complex, and unlimited-length long integers)
Python etc.

 It supports object-oriented programming with classes and


multiple inheritances.

 Supports grouping into modules and packages.

 It offers error handling through the rise and catch of


exceptions.

 Python exhibits dynamic typing of data but easily catch


incompatible inputs.

 It features generators and comprehensions.

 Python uses automatic memory management.

To add comment in Python, the comment must begin on the same


indent as the rest of the code. Before writing the comment “#” is
How to Use a Python used to indicate to the interpreter that the writing that follow is not
Comment: Block, Inline, a part of the code.
and Multiple
After writing a code on a line, “#” is used to add comment on the
Inline Commenting in same line.
Python
 Don’t explain code using comments.
 Your comments should be necessary.
Guidelines for inline
Python Comments  Concentrate on the why and how

A helpful comment provides more relevant and significant


Helpful Vs Unhelpful information to the code while an unhelpful comment stresses what
Comments is already in the code.

How to Comment out You are allowed to consecutively make more that more single-line
Week: Week 2________________Name: __Theophilus_Amaye_________
Assignment: Required Reading: Programming Basic Class:CS105_Section 03P
Page 4 of 6 Date: _Due Nov 11, 2023___________ __

Ques NOTES:
Multiple Lines in Python comments, which can be make multiple-line comments.

How to Comment in a A block of code is multiple lines of code on the same indentation.
Block of Coded Doctrings can be used to add comments to code.

One-line docstrings Begin at the same indentation line as the scope, introduce the
comment with a triple quote and end with a triple quote.

Multi-line docstrings A multi-line doctring comment can be made by starting a triple


quote on one line, writing comments in multiple consecutive lines
and then ending the comment with a triple quote on the next line.

Difference Between  Docstrings primarily not meant for making comments. We


Comments and Docstring only consider it a comment as it a set of string without
Comments in Python values assigned to it.
 Python comments are used to add to segment of code,
while docstrings are used to note functions, classes and
modules.
 Comments are not included in the final program and are
purely for human understanding. On the other hand,
docstrings, which are also textual explanations, are more
structured and are embedded within the code itself.
 Comments provide additional information while docstrings
provide describe modules, functions and classes.
 Comments describe “why” and “how” but docstrings
describe only the “what”.
 Comments are not considered an official part of the code
but docstrings are embedded as a part of the code and can
be accessed using built-in help function and doc attribute.
Why Comment in Python Python comments serve multiple purposes, including acting as
reminders, offering documentation for code clarity, allowing
communication of logic and algorithms within the source code
without influencing program execution. Beyond documentation,
comments can also be valuable for testing and debugging in
Python.
 Implementing new code and commenting it out to ensure a
Ways to Use Python
Week: Week 2________________Name: __Theophilus_Amaye_________
Assignment: Required Reading: Programming Basic Class:CS105_Section 03P
Page 5 of 6 Date: _Due Nov 11, 2023___________ __

Ques NOTES:
comments for testing seamless integration into the existing system.
 Experimenting with different programming techniques by
commenting out code sections and evaluating each to
compare outcomes.
 Systematically identifying the origin of errors by selectively
commenting out and running specific parts of a program,
allowing for precise debugging.

Summary on Comments  Ensure they match the indentation level of the code they
in Python pertain to.
 Comments should commence with a # followed by a space.
 Docstrings are enclosed with triple quotes (""").
 While Python lacks a built-in mechanism for multiline
comments, you can use multiple lines beginning with hash
characters or utilize docstrings.
 Comments should explain the reasons and methods behind
the code.
 Docstrings should focus on describing what the code does.

There are two Python version that are in use. Python 3 has more
Hello World
features than version 2. To write a simple “Hello World” string of
code, we do so typing;

print("Hello, world")

Indentation
Instead of curly bracket, indentation (using tab or for spaces) is
used to create block of codes. e.g.

Types and Variables Python adheres to a fully object-oriented paradigm and is not
Week: Week 2________________Name: __Theophilus_Amaye_________
Assignment: Required Reading: Programming Basic Class:CS105_Section 03P
Page 6 of 6 Date: _Due Nov 11, 2023___________ __

Ques NOTES:
characterized by "static typing." There is no requirement to
explicitly declare variables or specify their types before utilizing
them. In Python, each variable is treated as an object.

Numbers Integer: to define an integer (a whole number), you do so by


stating myint. For example, 4 being a whole number will be stated
thus: myint = 4

Float: For a float number (number with a decimal), you state it


using myfloat. e.g. 8.3 in python should be written thus:
myfloat = 8.3

String: strings are basically made of words. To declare a string the


characters should be put in quotes.

Assignment can be done on more than one variable at the same


time, but operators (+,-, etc.) cannot be used between numbers
and strings. Just like it can’t be to mathematically evaluate a word
with a number.

Python Type Conversion

You might also like