Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
566 views
ubuntu2004
Kernel: Python 3 (system-wide)

COSC 130 - Homework 0

Kyle Anderson

Part 1: Arithmetic Operations

In this section of the assignment, we will demonstrate the following concepts:

  • Addition

  • Subtraction

  • Multiplication

  • Division

  • Exponentiation

print(7 + 2)
9
print(7 - 2)
5
print(7 * 2)
14
print(7 / 2)
3.5
print(7 ** 2)
49

Part 2: Variables

In this section of the assignment, we will demonstrate the following concepts:

  • Creating variables

  • Printing the value of variables

  • Operations with variables

  • Nonlinear execution in notebooks

x = 91
x = 42
print(x)
42
y = 7
print(y)
7
print(x/y)
6.0

Part 3: Comments

In this section of the assignment, we will demonstrate the following concepts:

  • Writing comments

  • Using comments to document code

  • Using comments to disable lines of code

# This is a comment print(2 + 5)
7
# In this cell, we will calculte sales revenue. sales = 173 # Monththly widget sales price = 16.98 # Price per widget revenue = sales * price # Monthly revenue print(revenue)
2937.54
print(12 / 6) # print(12 / 0) print(12 / 4)
2.0 3.0

Part 4: Strings

In this section of the assignment, we will demonstate the following concepts:

  • Creating strings

  • Storing strings in variables

  • Printing multiple items

print("Hello, world!")
Hello, world!
name = "Robbie Beane" print(name)
Robbie Beane
print("Hello, my name is", name)
Hello, my name is Robbie Beane
print("Hell, my name is ", name, ".", sep="")
Hell, my name is Robbie Beane.