Computer Science - Characteristics of Computing Devices
The magic you can perform with a smartphone, such as an Apple iPhone or a Samsung Galaxy, is illustrated by a few real-world examples. It is capable of casting spells that give you the ability to: • Communicate with individuals everywhere in the globe from a bed or a bathroom stall. • Use an Apple iPhone to play a fantastic game with outstanding graphics like Alto's Adventure • Take a high-resolution photo or video, the latter of which includes images and sound, and send it to anyone using a computer that is linked to the Internet. • Manage a small business • Participate in a real-time, full-motion video call FaceTime video calls • Using a smartphone app to view and control home or commercial environmental conditions Anyone seen a current smartphone in the early 20th century would have recognised it as a miraculous invention. The point is that you constantly utilise computing equipment, and while it's acceptable for consumers to regard them as something magical, the goal of IT is to remove this enchantment and replace it with knowledge. You deal with computers when you buy groceries or gas. For that matter, when you get in a car, you depend on the computer to safely transport you from point A to point B. You are undoubtedly interacting with a computing device when you sit down in front of a screen running Windows and use Microsoft Word to write an essay for class or a report for work. Where else do you come across computers? • Video game consoles like the PlayStation 3, Wii, and Xbox; tablets (like the Apple iPad) and phablets (phone/tablet combos); digital cameras; entertainment hardware like DVRs and televisions; clocks and watches; motorcycles; appliances like refrigerators and washing machines; cash registers; automated teller machines (ATMs); manufacturing machinery in factories; inventory management systems in warehouses; and Internet of Things
0 Comments
Introduction to Computer Science
Modern marvels like the International Space Station, driverless automobiles, breathtaking visual effects in movies, and almost instant access to the information of the whole human race (via the Internet) all depend on sophisticated devices called computers. Math is done incomparably quickly by a computer or other computing gear. Over time, some clever individuals have discovered a way to represent practically anything you can see or hear as a collection of numbers. With anything you can feel, touch, taste, or simply imagine about, people just like them are working diligently to accomplish the same thing. To be more precise, the majority of these representations—which we refer to as data—are composed of enormous series of ones and zeros. Before you realise that this "info" is actually just numbers, a fancy calculator that produces spectacular cinematic effects can sound like something from Jack and the Beanstalk. A little (okay, a lot) of math will allow a computer to alter (or even build from scratch) the sounds and visuals it generates because they are formed of numbers Programmers create commands that employ math to modify data in accordance with a pattern. Special effects creators, as well as everyone else who uses computers for work, use applications chock full of helpful commands to manipulate computers into doing various kinds of magic. Python Programming Language - Conditions Up until this point, the translator has carried out one command at a time. Conditions affect how this changes. IF, ELSE, IF In order for our script to execute the code in its block, a condition essentially needs to return True. If, elif, and else are the three crucial keywords in this sentence. The user enters a number that this script converts to an integer. When this number is less than ten, our first if statement determines if it is. Always keep in mind that comparisons only yield True or False. The code that is indented here is run if the return value is True. Python code blocks are identified with colons and indentations. If this condition returns False, the elif-block is reached and this condition is checked there. Here, the identical process takes place. Elif blocks can be as numerous as you like. If neither criterion is true, we enter the else-block. You can see how these fundamental if, elif, and else trees function in this flowchart. Of course, an elif or else block is not necessary. Simply create an if-statement and the rest of the script will run without the code if the condition is not met. NESTED IF-STATEMENTS
You can also put if-blocks into if-blocks. These are called nested if-statements.i f number % 2 == 0: if number == 0: print("Your number is even but zero") else: print("Your number is even") else: print("Your number is odd") So, here we have the first condition, which checks if the number is even. When it’s even it then checks if it’s a zero or not. That’s a trivial example but you get the concept. Python Programming Language-User Input
We have merely printed text onto the screen up until this point. However, we also have the option of entering our own data into the script. In this chapter, we'll examine user input and how to deal with it. Input Function We may retrieve user input from the console application using Python's input method. input = name ("Enter your name here:") print(name) The user's name is saved into the variable name when entered here. This variable can then be called and printed. number1 = input ("Enter first number: ") number2 = input ("Enter second number:") sum = number1 + number2 print("Result: ", sum) This illustration is a little deceptive. It appears that we are printing the sum after receiving two numbers as input. The function input always returns a string, which is a concern. As a result, when you enter 10, the variable's value is "10," which is a string. What occurs when we combine two strings, then? Simply put, we add one to the other. As a result, "15" and "26" would equal "1526" when added together. We must first typecast our variables if we wish to perform a mathematical addition. number1 = input("Enter first number: ") number2 = input("Enter second number: ") number1 = int(number1) number2 = int(number2) sum = number1 + number2 print("Result: ", sum) Our script is now effective. Always keep in mind that the input function returns a string, so if you wish to perform computations with it, you must typecast it.
Operators
The subject of operators is what we'll learn next. To handle variables or values and perform actions on them, we need operators. There are many various kinds of operators, and in this chapter, we'll discuss their variations and uses. Arithmetic Operators Arithmetic operators are the most basic operators. They are presumably familiar to you from maths.
Click ▸ to run the python interpreter below
Assignments Operators
We are also familiar with assignment operators as another category of operators. We use them to provide variables values, as their name already implies. Basically, we assign a value directly using these operators. The two sentences that follow each have the same impact. It's simply easier to write that way.
Click ▸ to run the python interpreter below
Comparison Operators We always obtain a Boolean when we employ comparison operators to compare two items. As a result, our conclusion can either be True or False. When working with conditions and loops, we employ comparisons. We shall discuss these two subjects in more detail in following chapters. A comparison returns True if it is accurate, and False if it is incorrect. Let's examine a few instances.
Click ▸ to run the python interpreter below
Logical Operators
To combine or connect Booleans or comparisons, logical operators are needed. I think this is best explained by examples, so let’s look at some.
Click ▸ to run the python interpreter below
VARIOUS OPERATORS
Other operators include bitwise operators and membership operators. However, some of them are unnecessary, and understanding others requires a little more programming expertise. Python Programming Language – Creating Variables
Python, creating variables is really easy. We simply select a name and give it a value. myNumber = 10 myText = "Hello" We have two variables declared here. One of them is a number, and the other is a string. Although there are some restrictions, you can essentially choose any name you wish. You cannot use reserved keywords like int or dict, for instance. Additionally, other than the underlining, the name cannot begin with a number or other special character. Python Programming Language –Data Types and Variable Data Types and Variables Probably in your math lessons, you have previously come across variables. They are essentially just placeholders for values. That applies to programming as well. The distinction is that we use a wide variety of data types, and variables can now hold values for both complete objects and numeric values. Types of Numerical Data The types of data that you are most likely already familiar with come from mathematics. Numerous types of numbers can be applied to mathematical procedures. It is, as you can see, pretty easy. An integer is simply a regular whole number that we may use to perform simple calculations. A float is a floating point number that extends the integer and allows decimal places. And a complex number is just a number that consists of both real and fictitious elements. Complex numbers should be ignored if you lack mathematical understanding of them. They are not currently required for your programming.
Strings A string is essentially just a text or a basic sequence of characters. Our text was a string when we printed it in the last chapter. Strings must always be included in quotation marks. Otherwise, the interpreter won't understand that they should be read like text. In Python, the word for String is str. Booleans In Python, booleans are most likely the most basic data type. They only have two possible values: True or False. A binary data type, that is. When we come to conditions and loops, we'll utilise it a lot. bool is the crucial word here. Sequences We shall discuss sequences in a subsequent posts. Sequences, though, are also data types, so we'll at least note their existence.
Python Programming Language – Running the Script
Now, all that remains is to execute the script we just wrote. This requires saving the script as a Python file. Then you can utilise the IDLE's integrated interpreter. Simply select Run > Run Module (or F5). Python Programming Language – HELLO WORLD
In order to comprehend the syntax of Python, we will begin with a very simple programme. When learning a new programming language, it is conventional to begin with a Hello World application. A Hello World application is simply a script that displays the text "Hello World!" This is especially simple in Python. print("Hello World!") As can be seen, this is a single-line Python programme. In other programming languages, printing a single text would necessitate defining a basic structure with functions, classes, and more. However, let's observe what is occurring. The very first thing we notice is the so-called function named print. This function outputs specific text to the screen when invoked. The text to be printed must be placed between the parentheses. Additionally, the quotation marks are a crucial element here. They indicate that the text is a string rather than a proper name. A string represents text as a data type. Without quotation marks, the interpreter will consider Hello World! to be a variable name and not a text. Consequently, we will receive an error message. Python Programming Language - PYCHARM
You may also choose to utilise a highly professional IDE with numerous features. For Python, use PyCharm. This development environment was created by JetBrains, a well-known and reputable business. It has a multitude of features, expert syntax highlighting, and an intuitive user interface. I would recommend it to every Python developer, but I believe it may be excessive and unnecessary for novices. However, that is your choice. If you are interested, the community edition is available for free download. |
AuthorAnything you need to know about computer science Archives
May 2023
Categories
All
|