Python Forum

Full Version: Need help writing simple code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It doesn’t even have to work, my dad is a programmer and he uses python mostly. His birthday is coming up and I want to make him a shirt. I found this picture online and I thought it was funny but I don’t think it’s in python. I’m hoping someone can help me out. It should be super simple.
I’m sorry if this isn’t the place for this type of thing, but I couldn’t find anywhere else! I’d do it myself if I could, and I can’t ask my dad to help that would ruin the surprise lol.

[Image: mockup.jpg?composition=%7B%22artwork%22%...&width=480]
looks like C, can you drink it?
Maybe CoffeeScript on a Coffee cup Wink
Similar will look like this in Python:
coffee = Coffee()
if coffee.empty():
    coffee.refill()
else:
    coffee.drink()
If want more text something like this.
import time

coffee = Coffee()
if coffee.status() == coffee.empty():
    time.sleep(10)
    return coffee.refilled()
else:
    coffee.drink()
(Mar-12-2018, 06:42 PM)snippsat Wrote: [ -> ]Maybe CoffeeScript on a Coffee cup Wink Similar will look like this in Python:
coffee = Coffee() if coffee.empty(): coffee.refill() else: coffee.drink() 
If want more text something like this.
import time coffee = Coffee() if coffee.status() == coffee.empty(): time.sleep(10) return coffee.refilled() else: coffee.drink()
Thank you so much!! I’m sure he’s going to love it! :)

(Mar-12-2018, 06:42 PM)snippsat Wrote: [ -> ]Maybe CoffeeScript on a Coffee cup Wink Similar will look like this in Python:
coffee = Coffee() if coffee.empty(): coffee.refill() else: coffee.drink() 
If want more text something like this.
import time coffee = Coffee() if coffee.status() == coffee.empty(): time.sleep(10) return coffee.refilled() else: coffee.drink()
What does time.sleep(10) mean?
(Mar-12-2018, 10:26 PM)isashay Wrote: [ -> ]What does time.sleep(10) mean?
Time it can take to fill a coffee cup Wink
So if coffee.empty() it will take 10 second(sleep) then it will return coffee.refilled().
The "//" means that the rest of the row is a comment (something for us a humans too read, not for the computer). To make a comment in python you use "#".
#This is a comment
Yes the same in Python.
# i am a software developer
(Mar-12-2018, 10:53 PM)snippsat Wrote: [ -> ]
(Mar-12-2018, 10:26 PM)isashay Wrote: [ -> ]What does time.sleep(10) mean?
Time it can take to fill a coffee cup Wink So if coffee.empty() it will take 10 second(sleep) then it will return coffee.refilled().
Oooh. I like that even better, thank you!!

(Mar-13-2018, 12:11 AM)PyBeginner Wrote: [ -> ]The "//" means that the rest of the row is a comment (something for us a humans too read, not for the computer). To make a comment in python you use "#".
#This is a comment
Thanks, i was wondering what that was lol