Hey, guys!


having a little problem in python, how can I square root number or a varible in python?

And I'm trying incoparate the os function of unix, like using the clear command. How could I do that in python


Thanks for your help

Recommended Answers

All 6 Replies

Ok, i Just remembered how to get the sqaure root thing going.

just need help on the other one.

thanks!

Ok, i Just remembered how to get the sqaure root thing going.

just need help on the other one.

thanks!

you can use os.system()

Ok thanks for the help!

So imported the module os and sys (though I'm not sure if I needed sys).
where do I go from there.

I just want to clear the screen in linux.

And for some reason my python beginners book doesn't show how to use the "os.system()" method.
If your guys wouldn't mind giving an example or link to one?

ok

The reason why the program wasn't working, using the "os.system()", I didn't encase the "clear" command with double quotes. (DUH!!!:P )

Here is a function that works both on Windows and Linux:

def clear_screen():
    """
    clear the screen in the command shell
    works on windows (nt, xp, Vista) or linux
    """
    import os
    os.system(['clear','cls'][os.name == 'nt'])

Hey thanks for the example.

That really got me thinking on how i should tweak my script.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.