Replies: 13 comments 13 replies
|
x = (1,4,6,3,5,7,2)
y = x.sort()
print(f"{x} sorted is {y}")This code sorts a list of numbers and outputs (1,4,6,3,5,7,2) sorted is (1,2,3,4,5,6,7) |
x = (1,3,5,7,9)
print(x)this code prints a list of numbers: |
import numpy as np
from scipy.optimize import curve_fit
# Define a linear function
def linear_func(x, m, b):
return m * x + b
# Sample x and y data
x_data = np.array([1, 2, 3, 4, 5])
y_data = np.array([2.1, 4.1, 6.0, 8.2, 10.1]) # Slightly noisy linear data
# Perform curve fitting
popt, _ = curve_fit(linear_func, x_data, y_data)
# Extract fitted parameters
m_fit, b_fit = popt
# Print fitted parameters
print(f"Fitted equation: y = {m_fit:.2f}x + {b_fit:.2f}")
|
def activationoverpot(a, i_FC, i_0):
V_act = a*np.log(i_FC/i_0)
return V_act
def fuelcellvoltage(E_nernst, V_act, V_ohm, V_conc):
V_FC = E_nernst - V_act - V_ohm - V_conc
return V_FC
### function
def motorvoltagecalc(motorconst, noloadi):
return motorconst*noloadi |
mm = 100.00
inches = mm / 25.4
print('%0.1f mm is equal to %0.2f inches' % (m, inches)) |
name=input("Enter your name")
print("Hello", name,"!") |
q = -k * (T2 - T1) / L # Fourier's Law
k = 200 # Thermal conductivity [W/m·K]
T1 = 100 # Temperature on side 1 [°C]
T2 = 25 # Temperature on side 2 [°C]
L = 0.01 # Wall thickness [m]
q = -k * (T2 - T1) / L # Negative because heat is flowing from hot to cold
print(f"Heat flux: {q:.2f} W/m²") |
T_total = k * (omega1**2 + omega2**2 + omega3**2 + omega4**2)
omega_eq = np.sqrt(m * g / (4 * k))These were lines that I used in my quadcopter model(translated from matlab to python) to display total thrust and rotor speed required to reach equilibrium |
|
1.my favorite summer spot is being with my family back home in Jordan and it could be in any quiet and relaxing place in nature. def square(n):
return n * n
for i in range(1, 6):
print(f"The square of {i} is {square(i)}")this code defines a function called square that return the square of a number then it uses the for loop to print the number with its square from 1-5 |
The code prompts user to enter a number and prints out in a sentence what the square of the number is, for example if user inputs the number 7 it becomes: |
|
Hello Class, My favorite summer spot is definitely on the water. I love boating on the weekends with my friends and family in the Long Island Sound and the CT River. My favorite place to go on the boat is Block Island! |
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [2, 4, 1, 3, 5]
plt.plot(x, y)
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("Random Graph")
plt.show() |

Uh oh!
There was an error while loading. Please reload this page.
Greetings!
I'm excited to get started with our exploration of computational problem solving for engineering problems. We'll use Python to make functions, plots, and analyze data and equations. Its one of my favorite classes and applications.
Let's get started by using the Discussion board. Its a public-facing discussion, so you don't have to use your name in any of these chats. Answer these three questions,
becomes,
All reactions