Wikipedia:Reference desk/Archives/Computing/2020 January 25

= January 25 =

Ubnutu 18.04.3 LTS
In Virtual Box, how can I expand the disc space? -- Thegooduser  Life Begins With a Smile :)  🍁 01:23, 25 January 2020 (UTC)
 * , more information is necessary. The nature of the guest VM will come into play here, as regards partitioning and provisioning extra volumes from the virtual media that VirtualBox can provide. There is more than one way to skin a cat here. You may be able to expand the virtual media (haven't checked, may depend on the volume type you specified at VM creation time.) The easiest way is just to add another virtual media volume that will be seen as a new connected physical disk, then format and partition it according to the guest's needs. And of course, you could always take advantage of shared folders and network storage, that will expand the available space to the VM while sharing it with the host, other guests, or other devices on your network. Elizium23 (talk) 23:19, 25 January 2020 (UTC)

What's wrong with this code?
For the record, this code is for a rock-paper-scissors game:

inp = "Yes" while inp == "Yes" or "yes": move1 = input("What move would you like to make?: ") move2 = input("What move would you like to make?: ") if move1 == "Rock" or "rock": if move2 == "Rock" or "rock": print("It's a draw!") elif move2 == "Paper" or "paper": print(move2,"beats",move1,"!") elif move2 == "Scissors" or "scissors": print(move1,"beats",move2,"!") elif move1 == "Paper" or "paper": if move2 == "Rock" or "rock": print(move1,"beats",move2,"!") elif move2 == "Paper" or "paper": print("It's a draw!") elif move2 == "Scissors" or "scissors": print(move2,"beats",move1,"!") elif move1 == "Scissors" or "scissors": if move2 == "Rock" or "rock": print(move2,"beats",move1,"!") elif move2 == "Paper" or "paper": print(move1,"beats",move2,"!") elif move2 == "Scissors" or "scissors": print("It's a draw!") inp = input("Would you like to play again? If so, type either 'Yes' or 'yes': ")

Futurist110 (talk) 01:34, 25 January 2020 (UTC)
 * I don't know whether this is actual code for a specific language. In most programming languages, indentation is ignored and the two "elif move1 == ..." will be interpreted as elif to the immediately preceding elif and not to something earlier with the same indentation. If your language is like that then it probably has an endif or similar to end the closest unterminated if. PrimeHunter (talk) 02:40, 25 January 2020 (UTC)
 * It's probably true that in most programming languages indentation is ignored -- but not in Python, which this code appears to be.
 * The obvious mistake I see is in the second line,
 * which should be
 * Hope this helps! --Trovatore (talk) 05:01, 25 January 2020 (UTC)
 * You could alternatively say "while inp in ['yes','Yes']", but preferably: "while inp.lower == 'yes'". 2601:648:8202:96B0:0:0:0:4FFF (talk) 06:42, 25 January 2020 (UTC)
 * All lines containg  suffer from this problem. If you set   you can simply test whether  .  --Lambiam 18:53, 25 January 2020 (UTC)
 * I should thank for this question, as I learned something interesting about Python's   operator from it.
 * The top-level takeaway is that  evaluates as , and therefore the   loop will never terminate (and similarly, the first branch of each of the succeeding conditionals will always be taken).
 * But at a deeper level of detail,  evaluates as   if   is , and otherwise as.
 * So the  condition, namely , evaluates as   if the user typed "Yes" &mdash; and otherwise it evaluates as.
 * I expect this is meant to enable assignment statements with a fallback. What constitutes a "pythonic" usage of this mechanism I'm not really sure.  I don't bellyfeel pythonicity yet. --Trovatore (talk) 23:12, 25 January 2020 (UTC)
 * Off topic comment The only programming language I know fluently is Java, and all I can say is, wow. Is this what all other languages are like, or does Python just have ridiculously simple syntax? -- Puzzledvegetable Is it teatime already?  03:03, 26 January 2020 (UTC)
 * , Python just has simple syntax.I'll return with an example in Rust in a minute moonythedwarf (Braden N.) 03:25, 26 January 2020 (UTC)
 * Example on Puzzledvegetable's talk page. moonythedwarf (Braden N.) 03:56, 26 January 2020 (UTC)
 * Python is simple because indentation matters. Therefore, teaching Python is a pain. Every lab results in repeating over and over and over: "Check your indentation." 135.84.167.41 (talk) 13:34, 28 January 2020 (UTC)
 * Example on Puzzledvegetable's talk page. moonythedwarf (Braden N.) 03:56, 26 January 2020 (UTC)
 * Python is simple because indentation matters. Therefore, teaching Python is a pain. Every lab results in repeating over and over and over: "Check your indentation." 135.84.167.41 (talk) 13:34, 28 January 2020 (UTC)


 * If you're interested in what other languages look like this is worth a browse. don't worry about the ".de" it's in English. Martin of Sheffield (talk) 11:14, 26 January 2020 (UTC)
 * , Can't forget Rosetta Code --moonythedwarf (Braden N.) 14:21, 28 January 2020 (UTC)
 * , Agreed, it's another good site, though possibly a bit advanced for this context. One nice use of the hello world site is to set up a test suite to see what languages are usable on a particular machine.  It acts as a nice check that a cluster is doing what is expected. Martin of Sheffield (talk) 15:01, 28 January 2020 (UTC)