ITT we only post python scripts

print  "Hello World !"

…dreams are only worth having if we are willing to fight for it . . . do we fight for this dream of “Hello World” ?

dead = 1
if dead:
    print "oh no you are dead!"

Here are two that I coded to speed up Geometry homework :slight_smile:

Cylinder Surface Area Finder

print "Welcome to cylinder_surface_area_finder..."
print "Please enter the radius of the base: "
radius = raw_input()

print "Thank you, please enter the height of the cylinder: "
height = raw_input()

base_area = float(radius) ** 2.0 * 3.141592654
total_base_area = float(base_area) * 2.0

base_circum = 2.0 * 3.141592654 * int(radius)
cylinder_height_area = float(base_circum) * int(height)
total_area = float(total_base_area) + float(cylinder_height_area)

print total_area

Cylinder Volume Finder

print "Welcome to cylinder_volume_finder..."
print "Please enter the radius of the base: "
radius = raw_input()

print "Thank you, now please enter the height of the cylinder:"
height = raw_input()

base = (float)radius ** 2.0 * 3.141592654
total_volume = (float)base * (float)height

print total_volume
import this
raw_inupt()

#include <stdio.h>

main()
{
printf("Darn!  Wrong language D'=
")
}

“”"

One day I was watching an introductional course to programming. They used Scratch to start with. When I later went to read more about Scratch it came to my mind, why not the same idea could work for Python too.

Scratch is an visual, building block based programming language, mainly meant for children. Here is a typical scene from Scratch:

http://scratch.mit.edu/files/help-screens/variableChangeBy.gif

What do you think about this? Myopinie, Blender could be an ideal environment to implement this. Scratch is based on Smalltalk, but could we do the same for Python? “Blender Python Ratz”?

“”"

Anyone want to comment this?

I was thinking using the predefined parser-object of Python, the same method as is used to colorize/highlight the code. Do you think that is going to work?

Anyone want to be an OpenGL-artist for the blocks? Or is OpenGL the right choise?

Should i start a new thread for this?

Most, if not all of the stuff on Scratch’s website is very simple stuff, to make it viable for Blender it would have to do just about everything you can do with normal scripting, but don’t forget to have it for the BGE, a blocked script like that could be accessed with a controller logic brick.

why you put 3,1415blabla instead of the real value of pi

to do this

import math
pi = math.pi

You have your pi problem solved,and you don’t need to always type math.pi (This is why the variable) :smiley:

Ahh,this why i like python,no need to have complex knowledge about computer hardware,also Scratch programming language looks nice

Hey guys,i am learning python and i have a problem with a script

It’s about the Solving formula to 2nd degree (or level,i don’t know) of equations (i. e. a maximum of n**2)

ax**2 + bx + c = 0

to

x = (-b ± sqrt(b**2 - 4 * a * c)) / (2 * a)

import math

a = input("a = ")
b = input("b = ")
c = input("c = ")

discriminante = b**2 - 4 * a * c

preresultadoa = -b + math.sqrt(discriminante)
resultadoa = preresultadoa / (2 * a)

preresultadob = -b - math.sqrt(discriminante)
resultadoa = preresultadob / (2 * a)

resultadototal = [resultadoa, resultadob]

print resultadototal

translation of variables,the variables are in portuguese,too lazy

discriminante - the value in the square root zone
preresultadoa and preresultadob - preresult
resultadoa and resultadob - result
resultadototal - total

and the error

Traceback (most recent call last):
  File "C:/Formula resolvente.py", line 9, in <module>
    preresultadoa = -b + math.sqrt(discriminante)
ValueError: math domain error

do you think is the math.sqrt ?

how do i solve this

If your discriminate is negative, you’d get back a complex value, so you have to ensure the discriminate is positive.

Well,actually if

sqrt(-n) = critical error

but i’ll add an error system with try/exept

but is there any other way

Well, what values are you giving the script to produce that error, or is it for any values?

I get nans out when I pass negatives to sqrt functions.