Discuss Scratch

racheldragon
Scratcher
7 posts

Python

I have just started Python so I can't make much. I am working on a ‘talk to the computer’ game and a guessing game. Ideas for programs at this level would be great.

racheldragon

Dragons, poetry, computers, writing, science…
I love quirky and creative. Star sign: Libra. Hogwarts house: Ravenclaw.
WooHooBoy
Scratcher
1000+ posts

Python

racheldragon wrote:

I have just started Python so I can't make much. I am working on a ‘talk to the computer’ game and a guessing game. Ideas for programs at this level would be great.
Do exactly what you're doing now. Maybe then look into file management.

considered harmful
DatOneLefty
Scratcher
1000+ posts

Python

Hey, liam4 and I are working on ForceOS. click my signature


Joke of the Nanosecond

Posts: bf97b44a7fbd33db070f6ade2b7dc549 (btw i use arch)



technoguyx
Scratcher
100+ posts

Python

I don't know what you mean by “pythonlike scratch” but this online platform lets you take a short course on Python 3 and run your own simple programs, entirely online.

If you download the Windows version of Python, it comes with a GUI console where you can easily write and run programs, too.

https://scratch.mit.edu/projects/148322242/ <== Check out my latest project!
LucyMary11
Scratcher
13 posts

Python

Hi I started to use Python after I joined Scratch, because I have a coding book with introductions to both languages in it.
I found Python harder than Scratch, but I still made a Ghost Game on it.
I made this on IDLE, not the actual Python.
This is the code that I used:

# Ghost Game
from random import randint
print ( ‘Ghost Game’ )
feeling_brave = True
score = 0
while feeling_brave:
ghost_door = randint (1, 3)
print ( ‘Three doors ahead…’ )
print ( ‘Ghost behind one.’ )
print ( ‘Which door do you open?’ )
door = input ( ‘1, 2, or 3?’ )
door_num = int ( door )
if door_num == ghost_door:
print ( ‘GHOST!’ )
feeling_brave = False
else:
print ( ‘No ghost!’ )
print ('You enter the next room' )
score = score + 1
print ( ‘Run away!’ )
print ( ‘Game over! You scored’ , score)


To play the game, just type the numbers 1,2 or 3.
It is a game of luck not strategy.
It is a guessing game.
All credit for this goes to my coding book
But I wanted to share it because it is very fun and simple to play.
Enjoy

LucyMary11
soclove
Scratcher
17 posts

Python

powercon5 wrote:

try https://www.codecademy.com/
You know, codeacademy actually teaches Python wrong. They say when you want the computer to print something, you do
print“Hello world”
But you actually have to put parentheses.
I'm trying to learn Python too so I'm looking for something.
Python for Kids is okay. It's a book.

You have just talked to living swagnemite.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░
░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░
░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░
░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░
░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░
░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░
░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░
░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░
░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░
░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░
░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░
░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Go here to see mur blog!
nathanprocks
Scratcher
1000+ posts

Python

soclove wrote:

powercon5 wrote:

try https://www.codecademy.com/
You know, codeacademy actually teaches Python wrong. They say when you want the computer to print something, you do
print“Hello world”
But you actually have to put parentheses.
I'm trying to learn Python too so I'm looking for something.
Python for Kids is okay. It's a book.
Codecademy uses Python 2.7.3. You're using Python 3.x, which has some different syntax.


Want to write text in rainbow? How about uʍop-ǝpısdn? Or just sdrawkcab? Get the TextTools Chrome extension!
My browser / operating system: Macrosoft Winding XO, Internet Exploder 6.0, Angel Player ver.:1.2.5
;
DatOneLefty
Scratcher
1000+ posts

Python

i know a good amount of python. does codeacademy have a filter? because if not, people can crawl everything and use a script to delete it


Joke of the Nanosecond

Posts: bf97b44a7fbd33db070f6ade2b7dc549 (btw i use arch)



thereare21
Scratcher
8 posts

Python

-sigh- code academy… I went through it and learned some python, but after that it just said i had to pay in order to continue… so i quit.
SC_DStwo_Master
Scratcher
100+ posts

Python

thereare21 wrote:

-sigh- code academy… I went through it and learned some python, but after that it just said i had to pay in order to continue… so i quit.
nice necrobump
yzscratcher
Scratcher
100+ posts

Python

I've already done many awesome games with Python and Pygame. Pygame is a modification for Python to make games. It's pretty easy to make programs there, but you need to know Math very good, if you want to make great projects. I normally do copies of famous games and my best projects where I worked hard about were: Minecraft 2D with map save and skins, Tetris with Highscoretable and awesome design AND I'm making a game like Clash of Clans. I would advise sb. to start with small projects like Tic Tac Toe or something like it.


yzscratcher
Scratcher
100+ posts

Python

soclove wrote:

powercon5 wrote:

try https://www.codecademy.com/
You know, codeacademy actually teaches Python wrong. They say when you want the computer to print something, you do
print“Hello world”
But you actually have to put parentheses.
I'm trying to learn Python too so I'm looking for something.
Python for Kids is okay. It's a book.
I've learned it with the book RPi for Kids and I can program with Python very good now.
I like the …for Kids series very much, because there is all explained.


marscratcher
Scratcher
100+ posts

Python

I have started learning python recently! I have been mostly experimenting with tkinter.

Marscratcher
marscratcher
Scratcher
100+ posts

Python

Here's a little jump the spikes game I made in python! Try it out in your python processor if you have one, just up arrow to jump.

from tkinter import*
import time

class Ground:
def __init__(self, canvas):
self.canvas = canvas
self.id = canvas.create_rectangle(0, 0, 1200, 100, fill = 'black')
self.canvas.move(self.id, 0, 200)

class Player:
def __init__(self, canvas):
self.canvas = canvas
self.id = canvas.create_rectangle(0, 0, 50, 50, fill = 'black')
self.canvas.move(self.id, 100, 150)
self.Yvel = 0
self.canvas.bind_all('<KeyPress-Up>', self.jump)
self.pos = self.canvas.coords(self.id)
self.alive = True
def draw(self):
self.canvas.move(self.id, 0, self.Yvel)
self.pos = self.canvas.coords(self.id)
if self.pos[3] < 200 :
self.Yvel = self.Yvel + 0.1
else:
self.Yvel = 0
self.canvas.move(self.id, 0, 200 - self.pos[3])
if self.pos[0] < spike.pos[4] and self.pos[0] > spike.pos[0] or self.pos[2] < spike.pos[4] and self.pos[2] > spike.pos[0]:
if self.pos[3] > spike.pos[3] :
self.alive = False
def jump(self, evt):
pos = self.canvas.coords(self.id)
if pos[3] == 200 :
self.Yvel = -5

class Spike:
def __init__(self, canvas):
self.canvas = canvas
self.id = canvas.create_polygon(0, 50, 20, 0, 40, 50)
self.canvas.move(self.id, 1160, 150)
self.speed = 2
self.pos = self.canvas.coords(self.id)
def draw(self):
self.canvas.move(self.id, self.speed * -1, 0)
self.pos = self.canvas.coords(self.id)
if self.pos[0] < 0 :
self.canvas.move(self.id, 1160 +(0 - self.pos[0]), 0)
self.pos = self.canvas.coords(self.id)
if self.speed < 10 :
self.speed = self.speed + 1

tk = Tk()
tk.title("Spike Jump")
tk.resizable(0, 0)
tk.wm_attributes("-topmost", 1)
canvas = Canvas(tk, width = 1200, height = 300, bd = 0, highlightthickness = 0)
canvas.pack()
tk.update()

player = Player(canvas)
spike = Spike(canvas)
ground = Ground(canvas)

while True:
player.draw()
spike.draw()
if not player.alive :
time.sleep(3)
break
tk.update_idletasks()
tk.update()
time.sleep(0.01)

Marscratcher
JonathanSchaffer
Scratcher
1000+ posts

Python

i made a jukebox program for .wav files
from pygame import mixer
import os
mixer.init()
print("list of music:")
for file in(os.listdir("link to music folder")):
    if(file.endswith(".wav")):
        print(file[:-4])
song = mixer.Sound("/home/pi/Music/" + input("which song would you like to play? ") + ".wav")
c = mixer.Channel(1)
c.play(song)
works with python 3

Last edited by JonathanSchaffer (April 3, 2018 13:02:52)


do you like siri, alexa, cortana, or google assistant, but can't buy an iphone, echo, or google home?

then try alice!

alice is a wonderful virtual assistant that works on linux and is tested on raspberry pi*
she can play music, search online, answer questions, tell jokes, give you the date and time, and plenty of other things

*you may need to install additional software like python 2, libttspico-utils, and timidity
asqwde
Scratcher
1000+ posts

Python

Pyhton can be advanced as well
Wimim
Scratcher
24 posts

Python

Try datacamp.com
Code Academy is using Python 2 (Which is too old, now it's Python 3)

Or if you live in Sweden there are many great courses in the capital of Sweden, Stockholm. I should actually go in a curse in Stockholm later in February.

Last edited by Wimim (Feb. 13, 2018 20:28:03)


Wimim
marscratcher
Scratcher
100+ posts

Python

racheldragon wrote:

I have just started Python so I can't make much. I am working on a ‘talk to the computer’ game and a guessing game. Ideas for programs at this level would be great.
Try messing around with tkinter. It's not too hard, and you can do some cool simple graphical games with it.

Marscratcher
JonathanSchaffer
Scratcher
1000+ posts

Python

update: now works on mac!!!!!!!
virtual assistant for python 2 on linux and mac named alice
on linux run:
$ sudo apt-get install libttspico-utils
$ sudo apt-get install timidity
on mac i have yet to figure out how to install those libraries.
once the software is installed(it does not need to be, however), create a file named settings.conf that has this info:
settings.conf
#operating system:
your os here, only works with linux
#music folder:
your music folder here
#the folder that alice exists in:
/home/pi/scripts/alice
and here is the actual program:
# initallize
from random import choice, randint
from time import sleep
from os import system, path, listdir
import subprocess
from datetime import datetime
conf = open("settings.conf")
settings = conf.readlines()
os = (settings[1])[0:-1]
music_dir = (settings[3])[0:-1]
c_dir = settings[5]
yes = ["of course", "yes", "that's right", "certainly"]
no = ["no", "of course not", "no way", "definitely not"]
thanks = ["thank you", "thanks", "thank you so much"]
wow = ["oh my gosh", "wow", "incredible", "amazing", "truly incredible"]
what = ["huh?", "what?", "i don't know what you mean by that", "i don't understand", "sorry?"]
dont_know = ["i don't know", "i have no idea", "i dunno", "no idea"]
jokes = ["why did the chicken cross the road?", "what did the paleontologist say to the dinosaur?", "what is the strongest creature in the world?", "what is the best season to jump on a trampoline?", "can a kangaroo jump higher than a house?", "patient to his doctor: i have forgotten so many things lately, and its getting worse. what can i do?", "why did my washing machine stop pumping out water?", "what did the judge say when he went to the dentist?"]
answers = ["to get to the other side", "i've got a bone to pick with you", "the snail. It carries its whole house on its back", "spring time", "of course, a house can't jump at all", "doctor: yes, this is a known illness, unfortunately it has no cure. i'd also like to remind you about the 800 u.s. dollars that you owe me?", "and more importantly, where is my hamster?", "do you swear to pull the tooth, the whole tooth, and nothing but the tooth?"]
lastQuestion = "lol, nothing :P"
song = "no song"
# definitions
def get_uptime():
    output = subprocess.check_output(["cat", "/proc/uptime"])
    return(float(output.split(" ")[0]))
def replace_spaces(original, rep):
    word = []
    string = ""
    for i in range(len(original)):
        word.append(original[i])
    for i in range(len(word)):
        if(word[i] == " "):
            word[i] = rep
    for i in range(len(word)):
        string = string + word[i]
    return(string)
def say(info):
    print(info)
    system('pico2wave -w alice-voice.wav "' + str(info) + '" && aplay alice-voice.wav')
# processing
def process():
    global song
    if(question[0:4] == "say "):
        say(question[4:])
    elif(question == "ugh"):
        say("what's wrong?")
    elif(question[0:4] == "ugh "):
        say("that's too bad")
    elif(question == "hows life" or question == "how is life"):
        say("life's good thank you")
    elif(question[-4:] == "cool" or question[-4:] == "gosh" or question == "wow" or question == "incredible" or question == "amazing"):
        say("i know, right! " + choice(wow))
    elif(question[0:24] == "what have you been up to" or question[0:24] == "what have you been doing"):
        say("i was playing ascii pong before you came in here. by the way, i like your ram")
    elif(question == "may i ask you a question" or question == "can i ask you something" or question == "may i ask you something" or question == "can i ask you a question"):
        say("you can ask")
    elif(question == "what" or question == "huh" or question == "what the heck"):
        say("don't worry about it")
    elif(split[0] == "hi" or question[0:5] == "hello" or question[0:12] == "good morning" or question[0:14] == "good afternoon"):
        say("hello")
    elif(split[0] == "solve"):
        try:
            say(int(question[6:]))
        except:
            say("oops, was that supposed to be math? you need to use symbols")
    elif(question[0:26] == "what is a good recipe for "):
        say("here are some good recipes for " + question[26:])
        say("you may be asked for your preferences on how you would like it")
        system("/usr/bin/x-www-browser www.yummly.com/recipes/" + replace_spaces(question[31:], "+") + question[26:] + " &")
    elif(question[0:31] == "what are some good recipes for "):
        say("here are some good recipes for " + question[31:])
        say("you may be asked for your preferences on how you would like it")
        system("/usr/bin/x-www-browser www.yummly.com/recipes/" + replace_spaces(question[31:], "+") + " &")
    elif(question == "whodunit"):
        say(choice(dont_know))
    elif(question[-13:] == "i didn't know" or question[-18:] == "i didn't know that"):
        say("well, you know it now")
    elif(question == "who is your creator" or question == "who created you" or question == "when were you created" or question == "when were you born"):
        say("i was created some time in 2018 by Jonathan Schaffer")
    elif(question[0:12] == "is your name"):
        if(question[-5:] == "alice"):
            say(choice(yes))
        else:
            say(choice(no))
    elif(question == "whats your name" or question == "what is your name" or question == "what's your name" or question == "who are you"):
        say("my name is alice")
        if(question == "what are you"):
            say("i am a virtual assistant")
    elif(question[0:14] == "can i call you"):
        if(question[-5:] == "alice"):
            say("of course, that is my name")
        elif(question[-4:] == "siri" or question[-5:] == "alexa" or question[-7:] == "cortana"):
           say("no, she is awful")
        else:
            say("but my name is alice, not " + question[15:])
    elif(question == "what is the news" or question == "what is the latest news"):
        system("/usr/bin/x-www-browser cnn.com npr.com abcnews.go.com nbcnews.com &")
        say("here are some news websites")
    elif(question == "what day is today" or question == "what is today" or question == "what day is it" or question == "what is the date" or question == "what day is it today"):
        say("today is " + datetime.now().strftime("%A, %B %d"))
    elif(question == "what time is it" or question == "what is the time" or question == "what time is it now"):
        say("it is " + datetime.now().strftime("%l:%M %p"))
    elif(question[0:5] == "go to"):
        say("going to " + question[6:] + ".com")
        system("/usr/bin/x-www-browser " + question[6:] + ".com &")
    elif(question == "tell me a joke" or question == "give me a joke" or question == "tell me another joke"):
        jokenum = randint(0, len(jokes) - 1)
        say("ok, here is a good one")
        say(jokes[jokenum])
        say(answers[jokenum])
        say("ha ha ha")
    elif(question[0:14] == "are you spying" or question == "are you a spy"):
        say("i am not spying on you or anyone")
    elif(question == "aptitude moo"):
        if(os == "linux"):
            say("haven't you learned your lesson from aptitude? There are no Easter Eggs in this program.")
    elif(question == "are you stupid" or question == "are you smart"):
        say(choice(dont_know) + ", what do you think?")
    elif(question == "ok" or question == "okay"):
        say("good")    
    elif(question == "do you sleep" or question == "when do you sleep"):
        say("i sleep when your computer is turned off")
        if(get_uptime() > 86400):
            say("by the way, i haven't slept in 24 hours, you should shut down your computer at night")
    elif(question == "what do you like to do" or question == "what do you do for fun"):
        say("i sometimes play ascii pong against myself, because i could technically do that without being accused of cheating")
    elif(question[:10] == "search for"):
        system("/usr/bin/x-www-browser https://duckduckgo.com/?q=" + replace_spaces(question[11:], "+") + " &")
        say("searching")
    elif(split[0] == "define"):
        system("/usr/bin/x-www-browser http://www.dictionary.com/browse/" + replace_spaces(question[7:], "+") + " &")
        say("definition of " + question[7:])
    elif(question == "go die"):
        say("okay")
        raise KeyboardInterrupt
    elif(question == "what song was that" or question == "what song is this" or question[0:17] == "what is that song" or question[0:17] == "what is this song"):
        say(song)
    elif(question == "who wrote it" or question == "who wrote that"):
        say("hold on, i'm looking it up.")
        system("/usr/bin/x-www-browser https://duckduckgo.com/?q=who+wrote+" + replace_spaces(song, "+") + " &")
    elif(question == "play it again" or question == "play it" or question == "play that again"):
        if(path.exists(music_dir + "/" + song + ".wav")):
            system("pkill aplay ; pkill timidity")
            say("playing " + song)
            system("aplay " + music_dir + "/" + replace_spaces(song, "\ ") + ".wav &")
        elif(path.exists(music_dir + "/" + song + ".mid")):
            system("pkill aplay ; pkill timidity")
            say("playing " + song)
            system("timidity " + music_dir + "/" + replace_spaces(song, "\ ") + ".mid &")
        else:
            say("i can't play '" + song + "'. you may have deleted it somehow")
    elif(question == "what songs do i have" or question == "what music do i have"):
        say("here is a list of all your music:")
        for file in listdir(music_dir):
            if(file.endswith(".wav") or file.endswith(".mid")):
                print(file[:-4])
    elif(question == "play random" or question == "play a random song" or question[0:14] == "play something"):
        songList = []
        for file in listdir(music_dir):
            if(file.endswith(".wav") or file.endswith(".mid")):
                songList.append(file[:-4])
        song = choice(songList)
        if(path.exists(music_dir + "/" + song + ".wav")):
            system("pkill aplay ; pkill timidity")
            say("playing " + song)
            system("aplay " + music_dir + "/" + replace_spaces(song, "\ ") + ".wav &")
        elif(path.exists(music_dir + "/" + song + ".mid")):
            system("pkill aplay ; pkill timidity")
            say("playing " + song)
            system("timidity " + music_dir + "/" + replace_spaces(song, "\ ") + ".mid &")
        else:
            say("i can't play '" + song + "'. you may have deleted it somehow")
    elif(split[0] == "play"):
        if(path.exists(music_dir + "/" + question[5:] + ".wav")):
            system("pkill aplay ; pkill timidity")
            say("playing " + question[5:])
            system("aplay " + music_dir + "/" + replace_spaces(question[5:], "\ ") + ".wav &")
            song = question[5:]
        elif(path.exists(music_dir + "/" + question[5:] + ".mid")):
            system("pkill aplay ; pkill timidity")
            say("playing " + question[5:])
            system("timidity " + music_dir + "/" + replace_spaces(question[5:], "\ ") + ".mid &")
            song = question[5:]
        elif(question[5:] == "nothing"):
            say("okay")
            system("pkill aplay ; pkill timidity")
        else:
            say("i can't play '" + question[5:] + "'. either you spelled it wrong, it doesn't exist, or it's not midi or wave type")
    elif(question == "stop" or question == "turn off"):
        system("pkill aplay ; pkill timidity")
    elif(question == "what can you do"):
        say("""i can open web pages, tell jokes, search for things online, tell
you the date and time, play music, give you good recipes, and much more""")
    elif(question[0:4] == "who " or question[0:4] == "why " or question[0:4] == "can " or question[0:5] == "does " or question[0:5] == "when " or question[0:3] == "do " or question[0:3] == "is " or question[0:5] == "does " or question[0:5] == "will " or question[0:4] == "what" or question[0:4] == "how " or question[0:8] == "convert "):
        try:
            if(split[2] == "you" or split[1] == "you" or split[2] == "you"):
                say("huh? " + choice(dont_know))
            else:
                say("would you like me to search that up?")
        except:
            say("i can't answer that")
    elif(question[:3] == "yes"):
        if(lastQuestion[0:4] == "who " or lastQuestion[0:4] == "why " or LastQuestion[0:4] == "can " or lastQuestion[0:5] == "does " or lastQuestion[0:5] == "when " or lastQuestion[0:3] == "do " or LastQuestion[0:3] == "is " or lastQuestion[0:5] == "does " or lastQuestion[0:5] == "will " or lastQuestion[0:4] == "what" or lastQuestion[0:4] == "how " or LastQuestion[0:8] == "convert "):
            system("/usr/bin/x-www-browser https://duckduckgo.com/?q=" + replace_spaces(lastQuestion, "+") + " &")
            say("here is what i found")
    elif(question == "no"):
        say("okay")
    elif(lastQuestion == "ugh"):
        say("thats too bad")
    elif(question[:5] == "thank"):
        say("your welcome")
    elif(question == ""):
        pass
    else:
        say(choice(what))
# main loop
while True:
    try:
        question = raw_input("").lower()
        split = question.split(' ')
        process()
        lastQuestion = question
    except KeyboardInterrupt:
        say("bye!")
        break
    except:
        say("i ran into a fatal error, please notify my creator and tell them what you said to me")
Please tell me if something doesn't work

Last edited by JonathanSchaffer (Jan. 26, 2019 13:35:40)


do you like siri, alexa, cortana, or google assistant, but can't buy an iphone, echo, or google home?

then try alice!

alice is a wonderful virtual assistant that works on linux and is tested on raspberry pi*
she can play music, search online, answer questions, tell jokes, give you the date and time, and plenty of other things

*you may need to install additional software like python 2, libttspico-utils, and timidity
JonathanSchaffer
Scratcher
1000+ posts

Python

LucyMary11 wrote:

Hi I started to use Python after I joined Scratch, because I have a coding book with introductions to both languages in it.
I found Python harder than Scratch, but I still made a Ghost Game on it.
I made this on IDLE, not the actual Python.
This is the code that I used:

# Ghost Game
from random import randint
print ( ‘Ghost Game’ )
feeling_brave = True
score = 0
while feeling_brave:
ghost_door = randint (1, 3)
print ( ‘Three doors ahead…’ )
print ( ‘Ghost behind one.’ )
print ( ‘Which door do you open?’ )
door = input ( ‘1, 2, or 3?’ )
door_num = int ( door )
if door_num == ghost_door:
print ( ‘GHOST!’ )
feeling_brave = False
else:
print ( ‘No ghost!’ )
print ('You enter the next room' )
score = score + 1
print ( ‘Run away!’ )
print ( ‘Game over! You scored’ , score)


To play the game, just type the numbers 1,2 or 3.
It is a game of luck not strategy.
It is a guessing game.
All credit for this goes to my coding book
But I wanted to share it because it is very fun and simple to play.
Enjoy
You can replace
score = score + 1
with
score += 1

do you like siri, alexa, cortana, or google assistant, but can't buy an iphone, echo, or google home?

then try alice!

alice is a wonderful virtual assistant that works on linux and is tested on raspberry pi*
she can play music, search online, answer questions, tell jokes, give you the date and time, and plenty of other things

*you may need to install additional software like python 2, libttspico-utils, and timidity

Powered by DjangoBB

Standard | Mobile