• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 3 fuera de 29 páginas
Notas de lectura

Computer Programming Term 1 Python Study Notes (Syntax, Loops, & Data Structures)

Document preview thumbnail
Vista previa 3 fuera de 29 páginas

Description: Master your introductory computer programming and Python courses with these clear, highly detailed study notes! Covering everything from basic command-line navigation and data types to advanced loops, string manipulation, and dictionaries, this guide is built to help you ace your exams and debugging assignments. What's Covered:Programming Fundamentals: Syntax vs. semantics, variables, dynamic typing, explicit/implicit type conversions, and core operators. Control Flow & Logic: If-else statements, elif chains, boolean logic, and relational/logical operators (and, or, not). Loops & Iteration: while loops, infinite loop prevention, for loops, the range() function, and nested loops. Functions & Algorithms: User-defined functions, the def keyword, code tracing, trace tables, and algorithmic efficiency. Strings & Data Structures: String geometry, slicing, .format() templating, lists, and dictionary operations. Stop spending hours debugging syntax errors and get a clean, reliable study guide. Download your copy today and boost your grade!

Vista previa del contenido

Main Idea Explanation Examples

So what this would show here is that
Loops give us the count = 0
ability to the loops can repeat blocks of code
repeat blocks of based on certain conditions for an while count < 3:
code based on a exact number of times. print("I love python!")
certain condition, count += 1
or for an
exact number of While loop is similar and it would (they will count it less than 3 and 0
times. contain a certain condition on whether
and print i love python and will only
count 1 if it is + = and so that is
the code inside the loop will run or
The while loop what this code shows and on how it
not?
works very can be demoed for here)
similarly to If true then it will keep repeating
an if. while True:
A certain condition city = input("Please enter a city
controls whether name: (Nope to end) ")
the code inside of It will keep repeating checking the if city == "Nope":
it will run or not. condition each time after the code break
While the print("Oh! " + city + " is a cool
condition is true, spot.")
the code Four main parts of the loop all revolve
will keep repeating (if the code is true then it will input
around the control variable
- checking the the city to enter a name but it will
condition each not unless if a break and it will bring
time after the Oh!, city, is a cool spot and so that
code We initialize the control variable, is what this code would do.)
runs. create a while loop with condition
using control variable, code should The control variable needs to
his code will run if true, it would then update the be initialized before the loop.
output the word control variable for here. The keyword while
Hello 5 times: makes our while loop,
CS Python followed by our Boolean
Fundamentals — conditional: num < 5.
Unit 4
num = 0 Indented in the while loop is the
while num < 5: code that will
print("Hello") run - we print "Hello".
num += 1
num += 1 will increment our
There are four control variable by 1. This part
main parts of a keeps track of how many
while loop, and times the loop has iterated or
most of them repeated. After this line, we
revolve around loop back up to the while
what is known as and recheck our condition.
the control

,variable. # Initialize variables
total_sum = 0
The four basic count = 0
parts of our loop:
1. Initialize our print("Enter numbers to add to the
control variable running total.")
2. Create a while print("The program stops when the
loop with a sum exceeds 200.")
condition that
uses the control while total_sum <= 200:
variable try:
3. Code that # Prompt the user for input
should run while user_input = input("Enter a
the number: ")
condition is true
4. Update the # Convert input to a number
control variable (integer for this example)
number = int(user_input)

# Update the sum and the
count
total_sum += number
count += 1

except ValueError:
# Handle cases where the user
enters non-numeric input
print("Invalid input. Please
enter a valid integer.")
continue

# Output the results once the loop
condition (sum > 200) is met
print("") # Print a blank line for
readability
print("Sum:", total_sum)
print("Numbers Entered:", count)



name = input("Enter a name (STOP
Count Variable - Iterate = repeats to end): ")
Counts how many c=0
times the loop
runs or iterates. A count variable can check how while name != "STOP":
many times the loop runs or repeats c += 1
This is the code itself basically print("You entered " + name)
used in the name = input("Enter a name
example: (STOP to end): ")

, The code is used here and the name
name = always loops and runs, uses variable print("You entered " + str(c) + "
input("Enter a c to control the loop, and c+=x is names.")
name (STOP to used to go by increments of
numbers, After a name typed in this
end): ") (what this code would use would be
loop it will count the name and
c=0 reprompt them into that loop,and that it would show here that once
while name != STOP is obvious not to count it. you enter a name it will stop that
"STOP": name and make it different and so it
c += 1 would just stop the name in a way
print("You entered and so that is what this code shows
A sum variable is basically where it is
" + name) a count variable where it keeps a
here overall as a whole.
name = summary of how long they have ran
input("Enter a for and stuff and so that is what is And also it just shows as the name
name (STOP to shown here for the sum variable. was entered for here and so that is
end): ") what the result of this code would
print("You entered be.
" + str(c) + "
names.")


Name = loop runs

Variable c- is used
to control the loop

c+=1: goes by the
increments of the
names and is
needed to count
how many times a
user enters a
name

After they type a
name, it
enters the loop
and we
count that name.
Then we
reprompt them in
the loop.

STOP - not a
name and should
not be counted

c+=1: is at the
beginning of a
loop is because it

Información del documento

Año escolar
3
Subido en
28 de agosto de 2026
Número de páginas
29
Escrito en
2025/2026
Tipo
Notas de lectura
Profesor(es)
Computer programming term 1 notes.
Contiene
Todas las clases
$5.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
13
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes