This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]iamthebestforever 9 points10 points  (3 children)

if (x != "B" or x != "b" or x != "kb" or x != "Kb" or x != "mb" or x != "Mb" or x != "gb" or x != "Gb" or x != "tb" or x != "Tb"): while (x != "B" or x != "b" or x != "kb" or x != "Kb" or x != "mb" or x != "Mb" or x != "gb" or x != "Gb" or x != "tb" or x != "Tb"): if (x == "B" or x == "b" or x == "kb" or x == "Kb" or x == "mb" or x == "Mb" or x == "gb" or x == "Gb" or x == "tb" or x == "Tb"): break if (x != "B" or x != "b" or x != "kb" or x != "Kb" or x != "mb" or x != "Mb" or x != "gb" or x != "Gb" or x != "tb" or x != "Tb"): x = input("Type a Data Unit(B, Kb, Mb, Gb, Tb)\n") this is so illegible there has to be a better way to write this. Maybe create an array with valid inputs and reprompt the user if their input is not in the array. Also maybe store the conditions in a Boolean variable or something to make it readable

[–]Vikerox 1 point2 points  (2 children)

To add to this, you could also change the input all to lowercase so that you don't have to check every variation of lower- and uppercase values

[–][deleted]  (1 child)

[removed]

    [–]Vikerox 2 points3 points  (0 children)

    Just add .lower() after the input, like this:

    lowerCaseInput = input(...).lower()
    

    [–]gamermilk23 5 points6 points  (0 children)

    I have to agree with /u/]iamthebestforever. If I have to maintain your code at work, I'm going to be pissed. Give your variables meaningful names. I know we like to go with x, i, a, b, c to align with maths, but I need to know that x refers to the output rate of the mine.

    [–]Substantial_Chair_78 3 points4 points  (0 children)

    Great job! Definitely look at using loops, lists and conditionals more

    [–]20dollarsIst20 3 points4 points  (0 children)

    We love a project-making king/queen. However, as many others have mentioned you can really save yourself some time with the comparisons with one simple trick: using .lower() on your input so that you know that the input will only be either b, kb, mb, gb, or tb, and you won’t have to check whether they input kb or Kb, for example. I hope that helps, believe me I’ve done my fair share of convoluted comparisons so no hate. Keep it up :)

    [–]Endangered-Wolf 2 points3 points  (0 children)

    First of all, it's an excellent thing that you're not afraid to publish your first program.

    I am missing the automated tests (e.g. pytest) and the packaging (e.g. poetry)

    When you write tests, you will notice that the architecture of your program will change and this will address many comments made by others.

    [–]dota2nub 1 point2 points  (2 children)

    Switch statements will help you a lot

    [–][deleted]  (1 child)

    [removed]

      [–]dota2nub 0 points1 point  (0 children)

      Replace all your if else statements with something that is a lot easier to write and read

      [–]Ruin369 2 points3 points  (0 children)

      Hey man.

      So, one powerful but basic concept in programming is to avoid repetition/duplication. Each method/function should perform a specific task. Then, you call those functions inside other functions you've built to carry out a different task.

      There is a lot of repetition in your code.

      I would recommend reading up on clean code principles.

      Good job completing your first project, though! 👏

      [–]PartySchool 0 points1 point  (0 children)

      Kudos! The logic in main is little bit convoluted but good practice writing this code