PROBLEM SET 0: EINSTEIN | SOLUTION (CS50 PYTHON)

preview_player
Показать описание


––– DISCLAIMER –––

The following videos are for educational purposes only. Cheating or any other activities are highly discouraged!! Using another person’s code breaks the academic honesty guidelines. This solution is for those who have finished the problem sets and want to watch for educational purposes, learning experience, and exploring alternative ways to approach problems and is NOT meant for those actively doing the problem sets. All problem sets presented in this video are owned by Harvard University.

–––
Рекомендации по теме
Комментарии
Автор

Great hints. Improved the output with: print(f"E:", e)

DavidPinto
Автор

variable = int(input("M: "))
print(variable * ** 2)
simple version

PeacefulLifeOfThePresentMoment
Автор

Trying sooo hard to make them by myself, 1st time learning and althought is hard and actually managed to make it (a whole other way tho)

gabrielaorlando
Автор

thank you so so much . its really clean guide

khoon
Автор

def main():
mass = int(input("Enter mass as an integer in KG: "))
result = convert(mass)
print(f"Energy: {result} joules.")

def convert(mass):
c =
energy = mass * c ** 2
return energy

main()

doug_vm
Автор

e = eval(input("Give Mass in Kg: "))
print(e

Why so difficult lol :D

lachsmalstift
Автор

I found this problem the easiest by far. My solution:
m = int(input("m: "))
c =
E = m*c
print("E: ", end=""), print(E)

maksymkovalchuk
Автор

Think the main point was to re-use the square() function. If so this could work.

def main():
m = int(input("m: "))

c =
E = m * square(c)
print(f"E: {E}")

def square(n):
return n * n

main()

drunkenant
Автор

Thank You Very Very Very Very Very Very Very Very Much.

mastergreen
Автор

This is what i did

kilo = int(input("m: "))
energy =
print(f"E: {energy}")

raynamie
Автор

First, I completed this problem in my own way, but kept getting red when checking for answers. It kept saying that my outputs where "", even though I get correct answers when trying the code myself. After watching this video and changing my code to the exact code shown in the video, it still tells me it's incorrect and that my outputs are "", does anyone have the same problem or know how to solve it?

drws
Автор

it was so easy I was surprised after previous ones

klejnotnilu
Автор

Hello,
I receive extra three 0
Mass = int(input("enter kg"))
print(Mass * ** 2))

arte
Автор

If anyone wants to check out another way to solve this problem, here's my code.


def main():

m = int(input("What's your mass? "))
E = m * square(m)
print(E)


def square(c):
c =
return pow(c, 2)


main()

sir_rojas
Автор

E = m * (c ** 2) On this line. Why is there a * after the m?

jessipresten
Автор

def einstein_theory(user_mass):

speed_of_light =
energy = user_mass* speed_of_light**2
return energy

def main():
print("\t Lets prove E = mc^2")
user_mass = int(input("Enter the total amount of mass (in kg): "))
print(f"Energy is {einstein_theory(user_mass)} Joules.")


main()(did this and still got output wrong by the cs50
)

hridayagiri
Автор

I think I made it harder for myself haha!

def einstein():
x = int(input("Enter a number: "))
x = x * ** 2)
return x


print(einstein())

yuyum
Автор

IM bad at solving cs50p problem sets. can somebody help me?😶

yaserbatory
Автор

I did it another way but got stuck it kinda works
Def formula(energy):
mass = int(input(“mass:”))
energy = mass *( **2)
Return energy
Def main():
mass= int(input(“mass:”))
Mass = formula(mass)
Print(mass)

Main()

lthzjhp
Автор

I probably wasn't meant to do this but I just squared c on a calculator and put the number in my code haha

m = int(input("m: "))
print("e:", m *

Jacob-fxou