Post: Boredum made this.[Python]
01-11-2013, 05:11 AM #1
Complete Speed
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({});
    
import random
Meat = ['Ham','Turkey','Bologna','Meatball','Chicken','Steak','Tuna']
Bread = ['Wheat','White','Honey Oat','Italian']
Veggie = ['Tomato', 'Onion', 'Spinach', 'Lettuce','Jalapeno','Avocado','Banana Peppers']
Cheese = ['Pepper Jack','American','Swiss','Cheddar']
Sauce = ['Mayonaisse','Ranch','Buffalo Sauce', 'Honey Mustard', 'Mustard']
Drink = ['Coca-Cola','Pepsi','Awesome faceiet Pepsi','Awesome faceiet Coca-Cola','Cherry Limeade','Lemonade','Water','Powerade','Awesome facer. Pepper','Root Beer','Fanta']
Dessert = ['White Chip Macadamia Nut Cookie', 'Chocolate Chip Cookie', 'Awesome faceouble Chocolate Cookie', 'M&M Cookie','Ice Cream', 'Apple', 'Banana','Peanut Butter Cookie','Sugar Cookie']
Chip = ['Lays', 'Baked Lays', 'Cool Ranch', 'Nacho Cheese', 'Sun Chips']

x = random.randint(0,6)
y = random.randint(0,3)
b = random.randint(0,6)
d = random.randint(0,3)
v = random.randint(0,4)
n = random.randint(0,10)
m = random.randint(0,Cool Man (aka Tustin)
g = random.randint(0,4)

print (Meat[x] + ' - Meat'Winky Winky
print (Bread[y] + ' - Bread'Winky Winky
print (Veggie[b] + ' - Vegetable'Winky Winky
print (Cheese[d] + ' - Cheese'Winky Winky
print (Sauce[v] + ' - Sauce'Winky Winky
print (Drink[n]+ ' - Drink'Winky Winky
print (Dessert[m]+ ' - Dessert'Winky Winky
print (Chip[g]+ '- Chips'Winky Winky
stop = raw_input()



maybe the php on here messes up the code either way just view raw or whatever and copy it from here:
You must login or register to view this content.
made this quick little program when i was bored. took like 10 minutes.

boring. maybe someone could use this as a base. it's a subway program essentially. lol

what it does is take each item out of an array and puts it together in a nice meal planner.
maybe i can add pricing or add another type of restaurant.

to use this go to [url]www.python.org/download[/url] and download python 2.7 or 3.3 not sure if it works on 3.3 it should but go!

tell me what you think of it?
live demo via php
You must login or register to view this content.

credits to lovol for converting to php.

version 2.0:
You must login or register to view this content.

made it to where it fills the arrays from text files. only bug is it reads the \n on the newline so it makes the text after the items go down a line.

the reason for this is functionality. you can make it read whatever you want from the text files
or take out and add your own stuff.

if anyone can help please do.

screen shots:
You must login or register to view this content.
You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

The following 3 users say thank you to Complete Speed for this useful post:

Fer, Hazey, Mr.Picklemixel
01-15-2013, 08:44 PM #11
Pichu
RIP PICHU.
Originally posted by Kartom View Post
this code doesn't make it loop. it just sets it to where it asks a question before exiting.
you forgot that there is no == in python. it's the word "is" instead. so example it would be

if stop == "yes"
it would be
if stop is 'yes' or 'yes':
blah()

just friendly advice.


Actually, the == is a valid operator. == in Python, as many other languages, stands for is equal to. is stands for say, a is b; you are stating that a, logically, is the variable b.

== is equality comparison while is = identity comparison.

It would be == not is. You need to brush up on your Python or read a book. If you need, I have a college certified PDF on Python that I used for my college lesson when learning it.

Friendly advice. Smile

---
Edit: Did some searching: Here is a good thread on the subject. You must login or register to view this content.

This guy does a good job explaining it:

Originally posted by another user
SilentGhost and others are correct here. is is used for identity comparison, while == is used forequality comparison.The reason this works interactively is that (most) string literals are You must login or register to view this content. by default. From Wikipedia:
Interned strings speed up string comparisons, which are sometimes a performance bottleneck in applications (such as compilers and dynamic programming language runtimes) that rely heavily on hash tables with string keys. Without interning, checking that two different strings are equal involves examining every character of both strings. This is slow for several reasons: it is inherently O(n) in the length of the strings; it typically requires reads from several regions of memory, which take time; and the reads fills up the processor cache, meaning there is less cache available for other needs. With interned strings, a simple object identity test suffices after the original intern operation; this is typically implemented as a pointer equality test, normally just a single machine instruction with no memory reference at all.
So, when you have two string literals (words that are literally typed into your program source code, surrounded by quotation marks) in your program that have the same value, the Python compiler will automatically intern the strings, making them both stored at the same memory location. (Note that this doesn't always happen, and the rules for when this happens are quite convoluted, so please don't rely on this behavior in production code!)
Since in your interactive session both strings are actually stored in the same memory location, they have the same identity, so the is operator works as expected. But if you construct a string by some other method (even if that string contains exactly the same characters), then the string may be equal, but it is not the same string -- that is, it has a different identity, because it is stored in a different place in memory.
01-16-2013, 12:22 AM #12
Complete Speed
Do a barrel roll!
Originally posted by Pichu View Post
Actually, the == is a valid operator. == in Python, as many other languages, stands for is equal to. is stands for say, a is b; you are stating that a, logically, is the variable b.

== is equality comparison while is = identity comparison.

It would be == not is. You need to brush up on your Python or read a book. If you need, I have a college certified PDF on Python that I used for my college lesson when learning it.

Friendly advice. Smile

---
Edit: Did some searching: Here is a good thread on the subject. You must login or register to view this content.

This guy does a good job explaining it:


oh my bad. i wasn't compiling right when it wouldn't run. lol
sorry. i was off about that. the only reason why your code wouldn't run was because it was doubled up on the first line from the copy paste.
01-16-2013, 12:33 AM #13
Pichu
RIP PICHU.
Originally posted by Kartom View Post
oh my bad. i wasn't compiling right when it wouldn't run. lol
sorry. i was off about that. the only reason why your code wouldn't run was because it was doubled up on the first line from the copy paste.


It's ok. If you ever need help with Python I can try to help.

Also, I have a book on Python; it has my email registered to it so if I was to give it to your, I'd have to ask that you didn't share it but yea. (I'm trying to get my email removed... lol)
01-16-2013, 12:39 AM #14
Complete Speed
Do a barrel roll!
Originally posted by Pichu View Post
It's ok. If you ever need help with Python I can try to help.

Also, I have a book on Python; it has my email registered to it so if I was to give it to your, I'd have to ask that you didn't share it but yea. (I'm trying to get my email removed... lol)


yeah. i learned python a long time ago and just started to pick it up again.
if you would like to send me the book that'd be great. need something. btw i updated my py script to read from .txt files you should see if you can find away to help me remove the \n from reading line by line in a file and out putting to arrays. idk. but thanks.
01-16-2013, 12:42 AM #15
Pichu
RIP PICHU.
Originally posted by Kartom View Post
yeah. i learned python a long time ago and just started to pick it up again.
if you would like to send me the book that'd be great. need something. btw i updated my py script to read from .txt files you should see if you can find away to help me remove the \n from reading line by line in a file and out putting to arrays. idk. but thanks.


This book goes over System.IO so you should be able to understand how to read line by line.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo