top of page
  • Writer's pictureBrandon Barclay

Here are some helpful Python conversions.

"""

1. convert 100 Grams to pounds

"""

import numpy as np


# 1.1

#

# 1. Create a variable that represents your weight in grams.

# 2. Convert your weight to pounds.

# 3. Print your answer.

weight_in_grams = np.array([100])

weight_in_pounds = weight_in_grams * 0.00220462

print(weight_in_pounds)


# 1.2

#

# 1. Create a variable that represents your height in inches.

# 2. Convert your height in inches to feet.

# 3. Print your answer.

height_in_inches = np.array([70])

height_in_feet = height_in_inches / 12

print(height_in_feet)


# 1.3

#

# 1. Create a variable that represents your height in feet.

# 2. Add 6 inches to your height in feet.

# 3. Print your answer.

height_in_feet = np.array([5])

height_in_feet = height_in_feet + 6/12

print(height_in_feet)


# 1.4

#

# 1. Create a variable that represents your height in feet and inches.

# 2. Add 6 inches to your height.

# 3. Print your answer.

height_in_feet = np.array([5, 7])

height_in_inches = height_in_feet[1] + 6

height_in_feet[1] = height_in_inches

print(height_in_feet)


# 1.5

#

# 1. Create a variable that represents your height in feet and inches.

# 2. Subtract 6 inches from your height.

# 3. Print your answer.

height_in_feet = np.array([5, 7])

height_in_inches = height_in_feet[1] - 6

height_in_feet[1] = height_in_inches

print(height_in_feet)


# 1.6

#

# 1. Create a variable that represents your height in feet and inches.

# 2. Multiply your height in feet and inches by your weight in pounds.

# 3. Print your answer.

height_in_feet = np.array([5, 7])

weight_in_pounds = np.array([150])

height_in_feet_weight_in_pounds = height_in_feet * weight_in_pounds

print(height_in_feet_weight_in_pounds)


# 1.7

#

# 1. Create a variable that represents your height in feet and inches.

# 2. Divide your weight in pounds by your height in feet and inches.

# 3. Print your answer.

height_in_feet = np.array([5, 7])

weight_in_pounds = np.array([150])

height_in_feet_weight_in_pounds = weight_in_pounds / height_in_feet

print(height_in_feet_weight_in_pounds)


# 1.8

#

# 1. Create a variable that represents the number of days in a week.

# 2. Create a variable that represents the number of hours in a day.

# 3. Divide the number of hours in a day by the number of days in a week.

# 4. Print your answer.

days_in_week = np.array([7])

hours_in_day = np.array([24])

hours_in_day_days_in_week = hours_in_day / days_in_week

print(hours_in_day_days_in_week)





1 view0 comments
bottom of page