![]() In a letter to Yvonne Davet, Orwell described Animal Farm as a satirical tale against Stalin (" un conte satirique contre Staline"), and in his essay " Why I Write" (1946), wrote that Animal Farm was the first book in which he tried, with full consciousness of what he was doing, "to fuse political purpose and artistic purpose into one whole". Orwell, a democratic socialist, was a critic of Joseph Stalin and hostile to Moscow-directed Stalinism, an attitude that was critically shaped by his experiences during the Barcelona May Days conflicts between the POUM and Stalinist forces during the Spanish Civil War. Ultimately, the rebellion is betrayed, and under the dictatorship of a pig named Napoleon, the farm ends up in a state as bad as it was before.Īccording to Orwell, Animal Farm reflects events leading up to the Russian Revolution of 1917 and then on into the Stalinist era of the Soviet Union. It tells the story of a group of farm animals who rebel against their human farmer, hoping to create a society where the animals can be equal, free, and happy. ![]() Rather describe what that function actually does (the naming isn't really intuitive anyways), or why that check needs to be done.Animal Farm is a beast fable, in the form of a satirical allegorical novella, by George Orwell, first published in England on 17 August 1945. Or #This checks if choice is equal to 1 or equal to 2 In general write meaningful comments, just repeating the obvious like here #This defines a function called comment Putting comments after the statement commented is rare and confusing.Īs I've learned from the other answers (I'm certainly no python expert), it seems to be usual for python to rather use the docstring format, which applies after the documented statement. In most programming languages comments will appear before the statement, or at least side by side. Moreover, should I comment code above or below the line of code (I have to comment as this is a requirement)? There are other changes I would make, but I'll leave it at this to keep the review simple. Surely, the Cat→Human calculation is not the inverse of the Human→Cat calculation. Your formulae for choices 3 and 4 are the same. Those two quantities don't really have the same units, and that made your comment() function messy. Make the distinction between calendar years and human-equivalent years clear. Can you see the bug in your code, and why I didn't use double-ended inequalities there? Note that I haven't used that feature in the comment() function, though. Python supports double-ended inequalities, like 1 <= choice <= 4. Print("You have chosen Dog -> Human and the Dog age is", input_age)Ĭhrono_age = human_equiv_age / 11 if human_equiv_age Human and the Cat age is", input_age)Ĭhrono_age = 1 if human_equiv_age = 15 else (human_equiv_age - 22) / 4 2 Human_equiv_age = 15 if chrono_age = 1 else 25 (chrono_age - 2) * 4 Human_equiv_age = 11 * chrono_age if chrono_age Cat and the Human age is", input_age) Print a remark based on the human-equivalent age.Įlif 1 Dog and the Human age is", input_age) I've removed it in the code below, and am leaving it as an exercise to you to fix it. Your "restart" feature doesn't actually work. That defeats one of the principal advantages of packaging code into functions, which is to make it clear what the inputs and outputs are for a particular chunk of code. The presence of a global variable means that a reassignment could have effects beyond the scope of a function. The use of global variables makes it difficult to understand and maintain your code. The most important kind of documentation in Python is the docstring - and you didn't write any! (Redundancy simply doubles the burden of code maintenance, as you have to ensure that your comments are consistent with the code.) Your three comments simply restate the obvious, and are therefore obnoxious or harmful. Python is a language that is designed to be easily readable. My two most important remarks concern comments and global variables. ![]() ![]() Restart = (input("Would you like to restart?(Yes or No)")).lower() Print("You have chosen to generate a random human age.") If startage Human and the Cat age is", startage) Print("You have chosen Dog -> Human and the Dog age is", startage) If startage Cat and the Human age is", startage) If choice >= 1 and choice Dog and the Human age is", startage) Print("Welcome to the animal age calculator")Ĭhoice = int(input("Which age would you like to convert?(Enter the corresponding number)\n1. #This checks if choice is equal to 1 or equal to 2 #This makes the variable startage a global variable rather than a local variable Moreover, should I comment code above or below the line of code (I have to comment as this is a requirement)? #This imports the time and random modules Could someone suggest ways to simplify this code, or any other tips? All help is much appreciated. ![]()
0 Comments
Leave a Reply. |