Help on couple of easy computer science questions?

In summary: And there are 512x512 pixels. So how many bytes is that?In summary, the conversation discusses solving various problems and getting help from the teacher. The first question involves calculating the amount of memory needed for a 512x512 color image with 256 different levels of color. The second question has multiple parts, one involving finding values of x that satisfy a certain condition and the other involving short-circuit evaluation with an || (OR) statement. Similarly, the third question involves creating an example of short-circuit evaluation with an && (AND) statement. The speaker mentions having difficulty with these questions and reaching out to the teacher for assistance. They provide
  • #1
zzoo4
42
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
  • #2
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?
 
  • #3
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.
 
  • #4
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?
 
  • #5
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
 
  • #6
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
 
  • #7
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?
 
  • #8
yessirr
 

1. What is computer science?

Computer science is the study of computers and computational systems, including their principles, their hardware and software designs, their applications, and their impact on society.

2. What are some key concepts in computer science?

Some key concepts in computer science include algorithms, data structures, programming languages, computer architecture, and artificial intelligence.

3. How can I improve my problem-solving skills in computer science?

One way to improve your problem-solving skills in computer science is to practice solving coding challenges and problems, either on your own or through online resources. You can also study and understand different algorithms and data structures to help you approach problems more efficiently.

4. Are there any specific programming languages I should learn for computer science?

There are many different programming languages used in computer science, and the best one for you to learn will depend on your specific interests and goals. Some popular languages include Java, Python, C++, and JavaScript.

5. What are some common career options in computer science?

Some common career options in computer science include software engineer, data analyst, web developer, computer systems analyst, and artificial intelligence specialist. However, there are many other specialized roles within the field, and the possibilities are constantly evolving with new technological advancements.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
908
Back
Top