CS50 Week 0: Part 1
What is CS50????
CS50, or "Introduction to Computer Science," is a popular introductory course offered by Harvard University. It covers the fundamentals of computer science and programming. In this course, you will learn:
Programming Languages: You'll start with C, then move on to Python, SQL, and JavaScript.
Algorithms and Data Structures: You'll study searching, sorting algorithms, and data structures like arrays, linked lists, and trees.
Computer Systems: The course provides an introduction to how computers work, including memory management, file systems, and networking.
Web Development: You'll learn the basics of building websites using HTML, CSS, and JavaScript.
Problem-Solving: You'll develop your ability to break down problems and solve them through programming.
The course is designed for beginners and doesn't require prior coding experience. It's known for its rigorous content and hands-on projects.
Let's start our lessons
All problems has 3 thing
And we will try to know how the processing works actually.We can give inputs in any language but the computer only understand 0 or 1 binary language. It converts inputs into binary language then process the things ,gives a solution and converts the solution from binary to expected language output.
Lets understand the use of binary language in our real life.
Scenery 1
We have laptop,mobile or any device that have to charge in any moment.When we plug in the electricity then we find 1 but when we seperate it from the device there will no electricity in the device so we find 0. And everything works like that.
Now understand how we can represent numbers by 0 or 1
Lets understand by using bulb
One bulb is on then we represent the number 1
One bulb is on and one is off ….This represents number 2
Two bulb is on ….This represents number 3
One bulb is on and two bulb off …this represent number 4
By using these 2 bit (0 0r 1 ),we can represent any number
Now you are thinking what is bit???So lets talk about this
Bits:
Once upon a time, there was a small village where every house had a magic light switch. This switch could only do two things:
Off (0): The house stayed dark.
On (1): The house lit up brightly.
One day, a curious child named Leo decided to explore how the switch worked. He found that the village could communicate using only these two states — off and on. Every time he flipped a switch, the village reacted in a new way. He realized that these simple switches, though small and simple, could be used to send all kinds of messages by combining many of them together.
Leo understood that each switch represented a tiny piece of information, called a bit. Even though each bit was small (either 0 or 1), by using enough of them, you could create a whole world of possibilities.
Byte:
A byte is a unit of digital information that consists of 8 bits. A bit is the smallest unit of data, representing a 0 or 1, while a byte is larger and can hold 256 different values (from 0 to 255).
Bytes are used to represent a wide variety of data in computers and digital systems. For example:
Characters in text (like the letter "A" or the number "5") are often stored as bytes.
Images, sounds, and videos are all made up of bytes, which store more complex information.
Since a byte is made up of 8 bits, it can represent things like:
A letter (e.g., "A" or "B") using a character encoding system like ASCII or Unicode.
A number between 0 and 255 (because there are 256 possible values for a byte).
In simple terms, while a bit is like a light switch (on or off, 1 or 0), a byte is like a small box that can hold enough information to represent a character or small number.
How can we represent the number 217 by binary in byte
ASCII NUMBER
We saw that we can represent numbers by bits/byte .But how we can represent letters??????
Very thoughtful how can we do this???
So A represented by number 65 .
Now how we can represent the number K by byte??
K represent the number 75
ASCII code Table
Algorithms:
Imagine a story to understand
Lily loved baking cakes, and one day, she decided to make her famous chocolate cake. She had a secret recipe, but it wasn’t a normal recipe. It was a step-by-step set of instructions that always worked, no matter what.
To make the cake, Lily followed this algorithm:
Preheat the oven to 350°F.
Mix flour, sugar, eggs, and butter in a bowl.
Pour the mixture into a cake pan.
Bake for 30 minutes.
Let the cake cool before frosting.
Each of these steps had to be done in the right order, or the cake wouldn’t turn out right.Lily knew that if she followed the steps exactly, she’d always bake the perfect cake. This step-by-step process is what an algorithm is: a set of instructions that tells you how to do something in a specific order to get the desired result.
And for getting a output we need to follow algorithm by coding.
What is Pseudocode?
Pseudocode is a way of describing an algorithm in simple, human-readable terms. It uses plain language (rather than specific programming syntax) to outline the steps of a process. It's not meant to run on a computer, but rather to help you plan or understand the logic behind a program.
Think of pseudocode as a bridge between the idea of what you want to do and how you would actually write code to do it.
Example of Pseudocode:
Let’s take the example of making a cup of tea:
START
Boil water
Put tea bag in cup
Pour hot water into cup
Let the tea steep for 3 minutes
Remove tea bag from cup
Add sugar or milk (optional)
Stir tea
Enjoy your tea!
END
Explanation:
START and END mark the beginning and end of the process.
The steps between them are written in simple, clear language, describing what needs to be done, in order.
Pseudocode helps break down the task (making tea, in this case) without worrying about specific programming languages or details like syntax.