Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

I had a quiz that I got a few wrong on and I was curious if ya'll could illuminate me.

quote:

Given:

p = true

q = true

r = false

s = false

Determine the answer to the following:

not((p or q) and (r or s))

Thinking about this question, I'm fairly certain it returns as false. P & Q return true and r or s return false. So true and false = false. Not is a reverse operator so not(false)=true. Am I wrong?

Additional quiz question:

how many red triangles does the following code draw?

0,1,2,3?

quote:

def f(color):
Rect(0,0,100, 100, fill=color)

def g(color, num):
if (num == 7):
f(color)
if (color == "red):
f("black")
else:
f(color)


I'm fairly certain this wouldn't draw any because it has a syntax error. ASSUMING the syntax error was fixed, this still wouldn't draw any triangles because num is never declared before it's used?

Adbot
ADBOT LOVES YOU

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

My brain is a random answer generator you see.

I answered true on the quiz and it was marked wrong so I'm not crazy.

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

Dijkstracula posted:

Well, first you say it evaluates to false (incorrect) but then after you show your steps you say it evaluates to true (correct), so, there's a correct answer in there somewhere :v:


these sorts of questions are trivial to just check yourself:


$ python3 -q
>>> p, q, r, s = True, True, False, False
>>> not((p or q) and (r or s))
True
>>>



num is an argument to the function :confused:

I don't really know what to do with that question because f is never called except via g, and g is never called anywhere

Oh, ok. This is an intro class. I'm new to this. fair point, g is never called aaaannd the code has a syntax error. I'ma mail my professor.

Thank you fellas, you're all gorgeous people.

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

Magnetic North posted:

Are you sure you transcribed it correctly here?

Maybe not. Let me transcribe it exactly how it's set:

1.
pre:
Given:

p = true

q = true

r = false

s = false

Determine the answer to the following:

not((p or q) and (r or s))

2.
pre:
def f(color):
     Rect(0,0,100, 100, fill=color)

def g(color, num):
    if (num == 7):
        f(color)
    if (color == "red):
        f("black")
    else:
        f(color)
pre is not quote, been browsing for like 12 years :v:

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

mystes posted:

If this is a college class this might be a good time to try to transfer to another section where the professor isn't an idiot if possible, before you get more quiz/test questions that are bizarre/nonsensical and/or have incorrect answers

Oh my lord in heaven, you have no idea. This professor is awful. I thought I was just really bad at programming until I looked at her rate my professor and it's just a trail of 1.0s that goes on for pages with everyone universally agreeing she sucks. It's the middle of the semester. I'm stuck with this. :shepicide:

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

Jesus, I feel like I'm having a stroke. Help me goons:

pre:
counter = 10
while (counter>0):
   counter = counter//2


5
4
The loop never ends
3

How many times will this run?

My gut says 4 times. 10/2 =5, 5//2 =2, 2//1 = 1 //2 = 0.



pre:
 Which of the following values for n will cause the loop to never end/terminate?
Group of answer choices
10
8
7
9
Uh, none of the above? You're floor dividing, so at some point the answer will always be 0 and the loops will except? Hello? What's burning?

pre:

Re write as a correct loop based on the three parts of the loop

doAgain = "y"

 while doAgain == "y":

    word = input("Enter a word:")

    print("First letter of " + word  + " is " + word[0])

    doAgain = input("Type ‘y’ to enter another word and anything   else to quit.")

 print("Done!")

:psyduck:

BUT THIS ALREADY WORKS?!

edit: I thought about this and this loop has no exit condition.

so,
pre:
 1 doAgain = "y"
  2 
  3 while doAgain == "y":
  4 
  5     word = input("Enter a word:")
  6 
  7     print("First letter of " + word  + " is " + word[0])
  8 
  9     doAgain = input("Type ‘y’ to enter another word and anything   else to q    uit.")
 10     if doAgain != "y":
 11         print("Done!")
I think this is correct.

I may be missing something here but whenever I ran that first bit of code with a print(counter) it just outputs zero.

A Festivus Miracle fucked around with this message at 21:04 on Apr 21, 2024

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

RPATDO_LAMD posted:

i would assume by "correct loop" they do not mean "runs without errors" but "follows whichever dogmatic loop style-guide the professor told you to use in lecture"

It's this.

Another gem posted with roughly as much context as I had from her:

pre:
number = int( input ("Enter a value greater than 0"))
product = 0
while (number >=0):
     for x in range (1, 3):
          product = number * x + product
     number = int( input ("Enter a value greater than 0"))
print (product)
I have no loving clue what it does, but whatever it is it does it wrong :v:

Adbot
ADBOT LOVES YOU

A Festivus Miracle
Dec 19, 2012

I have come to discourse on the profound inequities of the American political system.

I'm going to take another class with this lady this fall, and I'm starting to realize that not only is she hopelessly incompetent at teaching, she's absolutely stuck on dogmatic ideas of what code should look like. I have no choice, it's the only offering of the class at the college :suicide:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply