You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frompprintimportpppp("Whatever Array or Json or other")
More prints
print(f"The median: {myVar_median}")
print(f"The standard deviation of maximum temperature is {round(temp_max_std, 1)}")
print("Average: ", round(df_avg,decimal_precision))
importdatetimenow=datetime.datetime.now()
print(now.strftime('%H:%M:%S'))
print(now.strftime('%Y-%m-%d %H:%M:%S'))
print(now.strftime('%H:%M:%S on %A, %B the %dth, %Y'))
IF
# In a lista= [10, 20, 30, 40, 50]
if30ina: print("in the list")
# ORifany(x==30forxina): print("in the list")
# ORifa.count(30) >0: print("in the list")
# Integer rangesmatchtemp:
case _ iftemp<-2:
cold.append(temp)
case _ iftemp<2:
slippery.append(temp)
case _ iftemp<15:
comfortable.append(temp)
case _ iftemp>=15:
warm.append(temp)
# Integersmatchstatus:
case400:
return"Bad request"case404:
return"Not found"case418:
return"I'm a teapot"case _:
return"Something's wrong with the internet"# Tuples# point is an (x, y) tuplematchpoint:
case (0, 0):
print("Origin")
case (0, y):
print(f"Y={y}")
case (x, 0):
print(f"X={x}")
case (x, y):
print(f"X={x}, Y={y}")
case _:
raiseValueError("Not a point")
# With a classfromenumimportEnumclassColor(Enum):
RED='red'GREEN='green'BLUE='blue'color=Color(input("Enter your choice of 'red', 'blue' or 'green': "))
matchcolor:
caseColor.RED:
print("I see the red!")
caseColor.GREEN:
print("The grass is green")
caseColor.BLUE:
print("The ocean is blue")
Check if it is a function
inspect.isfunction(fahr_to_celsius)
# Check that the function has one parametert_params=list(inspect.signature(fahr_to_celsius).parameters.keys())
assertlen(t_params) ==1# Check if a variable existif'ones'inlocals():
# And print the value of the variableprint(ones)