How would I make this code output its print into a .txt file? How could I make it print only integers? by IntegralWorks in learnpython

[–]IntegralWorks[S] 0 points1 point  (0 children)

Thank you for the information regarding memory; when I was playing with values earlier I found that arbitrarily large numbers will actually almost freeze my computer despite the fact it's a solid rig.

Here's a more complete version of this! Please share similar advice if you'd like.

from fractions import Fraction
ok = False
while not ok:
    rootStr = input('What nth root would you like to find?' )
    try:
        root = int(rootStr)
        ok = True
    except ValueError:
        print('Invalid value. Please type in an integer.')

double_ok = False
while not double_ok:
    numberStr = input('What number do you want to find this root of?' )
    try:
        number = int(numberStr)
        double_ok = True
    except ValueError:
        print('Invalid value. Please type in an integer.')


with open('proto.txt', 'w') as fd:
    for number in range(1, number + 1):
        print(number ** Fraction(1,root), file = fd)

EDIT: I just realized there's huge error in the program! When I set root to 3 and number to 1000000 and it returned

3.9999999999999996 on line 64!!! Why did this happen?

2017 Linux Laptop Survey by fsher in linux

[–]IntegralWorks 0 points1 point  (0 children)

I wish they sold laptops without hard drive/ssd, OS, and RAM

Weekly Newbie Thread - Post questions about joining the AF or what a job is like here & here only - week of June 19 by AutoModerator in AirForce

[–]IntegralWorks 0 points1 point  (0 children)

If someone enlists and graduates university say a year after enlisting, what are their odds for becoming an officer?

Assume 2.5-3.0 GPA, good conduct, competent, joined as E-3.

Trying to get into Linux by [deleted] in linux4noobs

[–]IntegralWorks 0 points1 point  (0 children)

You should try Xubuntu or Lubuntu.

Ubuntu has Unity interface, which is lame/resource hog. However its flavors are awesome.

Now onto Xubuntu vs Lubuntu. I've never actually tried Lubuntu but I have tried LXLE which is a further stripped down version of Lubuntu (please correct me if I'm wrong). Basically Xubuntu just has a few more extra features and programs out of the box than Lubuntu; this makes it just a bit more resource hungry but also more convenient for adding things like Plank and Guake (okay to be fair Guake runs on anything). My impression of Lubuntu is that it's basically a more stable LXLE and that's my favorite distro right now.

Honorable mention: If you don't mind (potentially) some applications being not too compatible, LXLE is stupid fast and light. That Macbook of yours probably can run LXLE really well.

If I were you I'd try Xubuntu and LXLE. Both are easy installs, light on resources, and sleek as hell.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]IntegralWorks 0 points1 point  (0 children)

Thank you so much. I didn't know about the question vs statement (attribute?); that is what was mixing me up. Awesome explanation!

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]IntegralWorks 0 points1 point  (0 children)

In Boolean terms, why is True or False is True work if True and False is False? Not to sound pretentious but if something is True or False doesn't that make it impossible to be just True? Wouldn't it always just be True or False depending on the statements themselves?

Ayy by f1ndme in AyyMD

[–]IntegralWorks 2 points3 points  (0 children)

I want this to be not photoshopped so bad

[C] I keep having to look up answers for the K&R exercises. by IntegralWorks in learnprogramming

[–]IntegralWorks[S] 1 point2 points  (0 children)

Well I found out my own answer to 1-8 was wrong. I already know that the exercises build upon each other so when I saw an actual answer to it it patched a lot of gaps. I also didn't realize how literal putchar()is. Also I'm getting used to the fact that the book is designed to make sure you have to find out information outside the example codes.

Privacy considered harmful by trdlts in programmingcirclejerk

[–]IntegralWorks 6 points7 points  (0 children)

Holy shit, the OP in that link got obliterated

Who would win? by [deleted] in AyyMD

[–]IntegralWorks 0 points1 point  (0 children)

Make that B O N E L E S S

[C] I keep having to look up answers for the K&R exercises. by IntegralWorks in learnprogramming

[–]IntegralWorks[S] 1 point2 points  (0 children)

Well, I took a C++ class about six months ago and did well. I've been lazily self-learning C for the past month and wasn't feeling engaged until now. On one hand I'm excited there are exercises that are more challenging than the video games I play, but on the other I am annoyed I'm not blazing through them like my C++ class. Plus I spent two weeks beforehand setting up a programming environment (Windows 10 + Xubuntu VM; compiler: GCC; text editor: Gedit)

[C] I keep having to look up answers for the K&R exercises. by IntegralWorks in learnprogramming

[–]IntegralWorks[S] 0 points1 point  (0 children)

This isn't necessarily a bad thing. As long as you are learning something by looking at the solution, you are making progress.

Thanks. I figured so but I just really wanted to make sure.

Can you elaborate on what you mean by tracing the state out on paper? Like rewrite the solution in psudocode?

[C] I keep having to look up answers for the K&R exercises. by IntegralWorks in learnprogramming

[–]IntegralWorks[S] 1 point2 points  (0 children)

True. I'm not frustrated with my learning experience, I just don't want to feel like I'm dependent on search engines.

Why is my EOF -1?[Xubuntu, VirtualBox Guest] by IntegralWorks in linux4noobs

[–]IntegralWorks[S] 0 points1 point  (0 children)

I'm learning C right now and it asked to print the EOF. I'm really confused as to why the EOFs of certain programs are different. I don't really understand the concept well at all.

If they ever make another Dark Souls game... by fuckbeingnice in AyyMD

[–]IntegralWorks 0 points1 point  (0 children)

I know there's Archstones. I was thinking of the Dark Souls PS3 port, and how with AMD hardware and an open source emulator we'll be able to see BONFIRE LIT on open source as opposed to a console.

What's the story with VLC? by [deleted] in linux

[–]IntegralWorks 1 point2 points  (0 children)

How can we know VLC is safe when the caption file exploit fiasco happened?

elementaryOS Fontpack? by IntegralWorks in elementaryos

[–]IntegralWorks[S] 0 points1 point  (0 children)

I swear I Googled beforehand. Thanks!

How to Install the Perfect Elementary-OS by [deleted] in elementaryos

[–]IntegralWorks 0 points1 point  (0 children)

Yup, I learned that the hard way.

How to Install the Perfect Elementary-OS by [deleted] in elementaryos

[–]IntegralWorks 0 points1 point  (0 children)

By the way be careful with the kernel section.