lecture 0 Flashcards

1
Q

where bits are derived from?

A

bits are binary digits, 0 and 1, two possibilities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

the only physical input of computer is

A

electricity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

in computer science, what number do we start counting

A

Computer scientists and, in turn, computer programs,
typically start counting from zero, just because it makes sense
because when everything is off, you might as well call that zero.

But at least in the computing world now, we’ll generally, by convention,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is a transistor?

A

A transistor is a semiconductor device used to amplify or switch electronic signals and electrical power. Transistors are one of the basic building blocks of modern electronics. It is composed of semiconductor material usually with at least three terminals for connection to an external circuit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what decimal number represent capital letter “A”

A
  1. In binary it is 01000001. This is ASCII, the American Standard Code for Information Interchange
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Nowadays, how many bits do computer use to represent a character?

A

8 bits, before it was 7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is a byte?

A

1 byte is just 8 bits, so I can say 1 byte can represent a character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how many characters ASCII can represent

A

2^8 = 256 characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

acronyms

A

acronyms

Are the members of your after-school club tripping over the name Student Parachuting League & Aerial Team? Why not use each word’s first letter to make an acronym, and call the club SPLAT? There, that’s better.

What do NASA, sonar, and scuba have in common? They are all acronyms. Not only does each letter come from the first letter of another word, but each group of letters is easy to pronounce as its own word. Though its roots are classic (acro means “tip” and nym means “name”), acronym is fairly new as English words go; it has only been around since the early 1940s.

Definitions of acronym
noun a word formed from the initial letters of the several words in the name
see more

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is a verb in programming language?

A

verbs are functions, a statement that gets the computer to do something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what are the types of code

A

source code input in compiler to have machine code (binary digits)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

terminal window , what is CLI is that similar to it

A

command line interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

in C, what is the long form of stdio.h

A

standard input output dot h

So standard io.h is just a very popular file
that is used in C programs that gives you the ability
to get input and output from the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is the shorthand notation for Ls in C?

A

list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is the symbol of an asterisk in C?

A

*

And that’s just a visual cue that that file is executable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is Rm in C?

A

remove in command line interface

17
Q

what is Mv in C?

A

Maybe now I want to change this program, and I don’t
want to write hello.c, but goodbye.c.
Well, let me close the tab up there.
And yes, I could go and Right click or Control click on it,
but, again, we don’t need to use the graphical interface.
Let me go ahead and instead do mv hello.c goodbye.c.
Mv is the move command.
And even though it would be nice if it’s called rename instead of move,
move just moves one file to another location or to another name.
So if I do mv hello.c goodbye.c.
Notice what happened at top left.
Now my same file is called goodbye.c.

18
Q

what is another name of folder?

A

In a moment we’re going to start writing more programs,
and so my account is going to get a little bit
messy with more and more files over the course of today.
So suppose you want to create a folder, otherwise known as a directory.
I’m going to go ahead and type mkdir for make directory.
And then the name of the directory I want to make, for instance, lecture.

19
Q

what is mkdir in C

A

So suppose you want to create a folder, otherwise known as a directory.
I’m going to go ahead and type mkdir for make directory.
And then the name of the directory I want to make, for instance, lecture.
You can call it anything you want, but if I’m in lecture, I’m writing code,
maybe I want to store all of today’s files in a lecture directory.

20
Q

what is cd in C?

A

Now, in the world of Macs and PCs we, obviously,
would just double click on a folder and voila we’re inside of it.
In a command line interface you need to be more deliberate.
So I’m going to do cd, for change directory,
then lecture, and then I’m going to go ahead and hit Enter.
And now notice, and now it might make more sense
why this whole time we’ve been seeing in blue this tilde lecture slash.
The tilde just means my so-called home directory.

“Now I’m inside this lecture directory in my terminal window.”

21
Q

what is .. in C?

A

.. means moving certain file to the previous folder single dot : . refers to the current directory

22
Q

what is rmdir in C

A

remove directorly

23
Q

what is the difference of hello.c and hello

A

DAVID MALAN: Oh, it is though.
So recall that we have two things in the story.
We have source code, which is the C code I’ve been writing.
And then machine code, which is the zeros
and ones that the computer understands.
I have been writing all of my code in the file called hello.c.
But after I compile it with make, the make program
creates a new file called hello that technically contains only zeros
and ones.
And that is the machine code that I’m actually
running when I do dot slash hello.
So again, I can use rm and I can get rid of the hello program
just like I did before.
And now we’re back at the very beginning of the story
where we wrote this code from scratch.
If I now type make, and let me do this now, ls.
Notice I’ve only got one file.
Let me now do make hello.
I see that cryptic output, but if I type ls again, now I have two files.
And that’s because only the green one with the asterisk is executable.
That is the machine code that the compiler has created for me.
And I should say and disclaim, I’ve been telling a little bit of a white lie
today.
Make itself is not actually a compiler.
We’ll see next week exactly what make is doing.
But it’s making it easier for us to actually compile our code,
but more on that next time.

24
Q

what many bits and the possibility of integers in C or most modern system

A

So integers, again, are implemented in C as these things ints.
Ints only use, it turns out, 32 bits total.
And you would only know that by having been taught it
or looked it up for a particular computer system.
But they on CS50 IDE, and most modern systems, an integer is only 32 bits.

And the catch is that if you want to support both positive numbers
and negative numbers, you can represent 4 billion or so total possible values.
But if you want to go as far to the left and as far to the right on the number
line that I’m describing.
You can only really count as high as 2 billion in the positive direction
and negative 2 billion in the negative direction.

for number that is higher than 2 billion (positive or negative), we should use the data type long

25
Q

how compiler may confused about the bug

A

And I can’t emphasize this enough.
Sometimes– I got lucky here and I only have one mistake, apparently,
in the error messages– it is not going to be uncommon
for you to have two errors, 10 errors, in like two lines of code.
This is because sometimes when you have errors in your code,
the compiler sometimes just gets confused.
And if it gets sufficiently confused, it starts thinking everything
is an error in your actual code.
So the most important takeaway is that no matter
how many errors you seem to have, always scroll up to the top of the output
and address the first error first.

26
Q

in C, if:

int x = 1;
int y = 2;

float z = x + y;

what is the value of z?

A

the answer is 0, because when two int interact, their answer can be only int, the decimals are discarded.

Having z assign to be float is irrelevant. cuz the result of operation is already set to be int

so convert x and y to be float,

use method (float)x

27
Q

the logical sequence for for loop in C

A

But for now just realize this says, initialize i to zero.
Check the condition.
And if i is less than 50 print hello, world.
Then update i.

for ( int i = 0; i > 0; i++)

28
Q

Can we use double code for char in C?

A

And this is because C is very specific when it comes to its data types.
All this time I’ve been using double quotes for strings,
but it turns out in C you have to use single quotes when
you’re comparing individual characters.

29
Q

what is C99

A

Implicit declaration of function meow is invalid in C99.

C99 is referring to the 1999 version of C the language we’re using,

30
Q

in Javascript, what will console.log (0.2+0.4) result in?

A

0.6000000000000001, the reason is computer in binary digits, 在電腦的角度, 這些小數點是除不盡的. 所以衹要電腦是計算小數點, 都會有不精准的情況, 所以在計算價錢的時候要特別注意

31
Q

in Javascript, how do make the code become comment

A

highlight then press ctrl + /

32
Q

console.log(sentence.substring(sentence.length-4)) . What is the purpose of substring

A

the argument in substring is that what LAST number of index of string the computer will show