avatarJake Cutter

Summary

The article "Coding w/ Python — part 3" provides an overview of Python programming concepts including operators, loops, functions, and arrays, with examples and references to external resources for further learning.

Abstract

This installment of the Python coding series delves into the practical application of various programming constructs within Python. It begins by emphasizing the importance of understanding variables and strings, which are foundational elements in programming. The article then breaks down the use of operators for arithmetic operations, boolean logic, and more complex mathematical functions. It proceeds to explain the concept of loops, illustrating how while and for loops can be used to execute repeated actions based on certain conditions, and introduces the use of continue and break to control loop behavior. The article also covers functions, which are blocks of code designed to perform specific tasks and can be reused, contributing to more organized and readable code. Lastly, it discusses arrays, detailing how they store multiple items and can be manipulated through indexing. The content is supplemented with code examples and references to educational platforms like "Learn Python" and "tutorialspoint," as well as a YouTube video from freeCodeCamp for readers seeking hands-on learning.

Opinions

  • The author stresses the significance of mastering variables and strings, considering them essential knowledge for programming in Python.
  • The article promotes the use of external resources such as "Learn Python" and "tutorialspoint" for practical coding exercises and further understanding of Python concepts.
  • A YouTube video by freeCodeCamp is recommended for its comprehensive tutorial on Python programming, indicating the author's endorsement of this resource for beginners.
  • The author suggests that while learning to code can be challenging, the abundance of available learning tools can greatly assist in the process.

Coding w/ Python — part 3

Welcome back to coding with python. In this article, we are covering operators, Loops, Functions, and arrays.

Photo by Sai Kiran Anagani on Unsplash

Last time we learned a little bit more about the tools that we can utilize during the coding process. They are common in a lot of coding languages and are pretty transferable. Today, we are going to cover the use of the entire toolbox to get a section done. This can include if/else and more( we’ll get into more detail later). It requires the use of variables and strings that we have already covered. These two are the most important to learn and drive into your brain. They show up everywhere. Learn it, live it, breathe it.

Operators

To start off, we have operators. An operator is the commands that utilize things like arithmetic and Lists. Addition, subtraction, multiplication. The exercise from part 2 covered a basic calculator. This can be considered an arithmetic operator( learn).

For example:

x= 7

y = 29

number = x + y

print(number) = 36

There are more complex strings that use scientific calculator methods using float and integral. Float is used for anything with decimals. There are also boolean operators. This is for a two answer kind of set up. Yes/no, If/then. This is a language of ones and zeroes.

Loops

Loops works with commands in lists of numbers and statements in order to formulate an answer. For example, while count < 5, x= 7. It takes orders from a condition that you set and prints out an answer.

Ex: Code from Learn Python

# Prints out 0,1,2,3,4

count = 0 while count < 5: print(count) count += 1 # This is the same as count = count + 1

After the # is a comment. As you can see the above code went from top to bottom it looked for a condition such as < 5. In addition, you have continue and break loops. Continue and break loops are used in conjunction with for/while loops. They can stop an f(x) and restart it.

Ex: From Learn Python

# Prints out 0,1,2,3,4

count = 0 while True: print(count) count += 1 if count >= 5: break

# Prints out only odd numbers — 1,3,5,7,9 for x in range(10): # Check if x is even if x % 2 == 0: continue print(x)

The above code sets up a while loop for > 5, but prints out only the numbers that are divisible by 2 ( % ).

Then you have else statements that you throw in after a while. This will only be executed if the while statement above it works.

Functions

Functions are a way of organizing and making the code more readable and repeatable.

def my_function()

print(my_funtion())

Arrays

An array holds items or values. Each piece in the array is called an element. Its placement within the array is an index.

Ex: Code from tutorialspoint

from array import *

array1 = array('i', [10,20,30,40,50])

for x in array1:
 print(x)

The code prints out 10–50 because its is taking from an array above it that choice the number bank. You can also find a specific part of the array.

Ex: tutorialspoint

from array import *

array1 = array('i', [10,20,30,40,50])

print (array1[0])

print (array1[2])
The chosen element from the array is inclosed in []

I am learning from a really good youtube video here. Its four hours of free coding lessons to get started on python by free code camp. I don’t get anything from this its just a really helpful tool. Learning to code is hard but there are a ton of resources out there to help get us through the process.

References:

Coding
Programming
Python
Engineering
Software Development
Recommended from ReadMedium