Help on couple of easy computer science questions?

AI Thread Summary
The discussion revolves around a student seeking help with computer science test questions after receiving their graded tests. Key issues include misunderstanding how to calculate memory for a 512x512 color image, where the student incorrectly guessed the answer. The student also struggled with identifying valid values for various conditions involving mathematical expressions and logical operators. Clarifications were provided regarding the need to show work for problem-solving, particularly for determining valid outputs for given conditions. Ultimately, the student expressed a better understanding after communicating with their teacher and is now able to approach the questions correctly.
zzoo4
Messages
42
Reaction score
0
I got my old tests back today. And I don't understand what i did wrong??
p.s. teacher is not available at the moment( sub//part time teacher).

1. How much memory does it take to hold a 512x512 color image with 256 different levels of color(states)??

Okay, this one I just guessed and divided 8bits by 262144 which is totally wrong..

2a. what values of x will cause the following to be true??
if(x<100 && x>0 && x%2==1) for this i put 99..

b. if (x>=0 && x%5==0) for this i put 5.

c. if (Math.sqrt(x))%1 == 1 && x>1 && x<50 ) i put 12.25 (okay obviously this is wrong).

3. Create an example of short-circuit evaluation with an || (OR) statement = include variable with explanation.

i put if ((x==y) || (y==x) b/c if one condition is true, the other one must be true.

4. Create an example of a short-circuit evaluation with an && (AND) statement. Include values and explanation.

i put if ((x!=y) || (y=x) b/c only one condition needs to be false , then other is false.



help me fix what I did wrong please?
 
Physics news on Phys.org
zzoo4 said:
I got my old tests back today. And I don't understand what i did wrong??
p.s. teacher is not available at the moment( sub//part time teacher).

1. How much memory does it take to hold a 512x512 color image with 256 different levels of color(states)??

Okay, this one I just guessed and divided 8bits by 262144 which is totally wrong..

2a. what values of x will cause the following to be true??
if(x<100 && x>0 && x%2==1) for this i put 99..

b. if (x>=0 && x%5==0) for this i put 5.

c. if (Math.sqrt(x))%1 == 1 && x>1 && x<50 ) i put 12.25 (okay obviously this is wrong).

3. Create an example of short-circuit evaluation with an || (OR) statement = include variable with explanation.

i put if ((x==y) || (y==x) b/c if one condition is true, the other one must be true.

4. Create an example of a short-circuit evaluation with an && (AND) statement. Include values and explanation.

i put if ((x!=y) || (y=x) b/c only one condition needs to be false , then other is false.



help me fix what I did wrong please?

You need to show more work on these questions. We are not able to offer much help (within the PF rules) if you just say you guessed at answers and show no work.

That said, on 1a) Your guess makes absolutely no sense. How many bits does it take to encode 256 levels of color per pixel? And if you have 512x512 pixels, how many total bits is that? How many bytes is that?
 
berkeman said:
You need to show more work on these questions. We are not able to offer much help (within the PF rules) if you just say you guessed at answers and show no work.

That said, on 1a) Your guess makes absolutely no sense. How many bits does it take to encode 256 levels of color per pixel? And if you have 512x512 pixels, how many total bits is that? How many bytes is that?


well, All I knew was bytes =8 bits. And there are 2^8= 256states..
I do not know what pixels are. And I just multiplied 256 by 256 and divided by 8bits.. Which wass wrong.
And for the rest of questions I am pretty sure that those don't really need work to be solved.
 
zzoo4 said:
well, All I knew was bytes =8 bits. And there are 2^8= 256states..
I do not know what pixels are. And I just multiplied 256 by 256 and divided by 8bits.. Which wass wrong.
And for the rest of questions I am pretty sure that those don't really need work to be solved.

A pixel is each dot on your display. You are correct that it takes 8 bits or 1 byte to encode each of the pixels. If there are 512x512 pixels, then how many bytes does it take to hold that 512x512 image?

And no, on the rest of the problems you can definitely show work. Please try to work out 2b) here -- what do each of the terms mean in the question? What is the intersection of those terms?
 
okay. I e-mailed the teacher, and I get how to do em now.

He said I got couple of them wrong due to questions have more answer.
for example.

2b. is 0 and all positive multiples of 5
 
berkeman said:
A pixel is each dot on your display. You are correct that it takes 8 bits or 1 byte to encode each of the pixels. If there are 512x512 pixels, then how many bytes does it take to hold that 512x512 image?

And no, on the rest of the problems you can definitely show work. Please try to work out 2b) here -- what do each of the terms mean in the question? What is the intersection of those terms?

if (x>=0 && x%5==0) // since x is greater than and equal to 0 and divided by 5 gives no remainder. it has to be either 0 or and thing multiple of 5. ex. 55%5==0.
So there's clearly more answer than just the number 5.

o and all positive multiples of 5
 
zzoo4 said:
if (x>=0 && x%5==0) // since x is greater than and equal to 0 and divided by 5 gives no remainder. it has to be either 0 or and thing multiple of 5. ex. 55%5==0.
So there's clearly more answer than just the number 5.

o and all positive multiples of 5

Good. Can you do them all now?
 
yessirr
 

Similar threads

Replies
3
Views
3K
Replies
5
Views
3K
Replies
2
Views
2K
Replies
1
Views
9K
Replies
5
Views
5K
Back
Top