0% found this document useful (0 votes)
229 views

Microsoft PowerPoint - QBasicFunctions

This week in Computer Science 1, students will learn about QBasic programming including built-in functions, computer concepts like networks and the internet, and project #1. QBasic has built-in mathematical and string functions that are part of the programming language and return values. Functions take inputs called arguments and return outputs. Students will complete a space cadet lab using variables and built-in functions to calculate fuel needs and polygon perimeters. They will also review networks, which allow connected computers to communicate and share resources, and protocols, which define rules for sending data.

Uploaded by

voltus88
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
229 views

Microsoft PowerPoint - QBasicFunctions

This week in Computer Science 1, students will learn about QBasic programming including built-in functions, computer concepts like networks and the internet, and project #1. QBasic has built-in mathematical and string functions that are part of the programming language and return values. Functions take inputs called arguments and return outputs. Students will complete a space cadet lab using variables and built-in functions to calculate fuel needs and polygon perimeters. They will also review networks, which allow connected computers to communicate and share resources, and protocols, which define rules for sending data.

Uploaded by

voltus88
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

This Week ...

Computer Science 1
Week 5 • QBasic Programming
Š Built
Built--in functions
• Computer Concepts
Š Networks
Š The Internet
• Questions on Project #1?

QBasic Built
Built--in
Functions

Built--in mathematics and tools


Built

QBasic Built-
Built-in QBasic Built-
Built-in
Functions Functions

• Built
Built--in Functions • Often, a function takes an input
Š part of the QBasic programming language Š it returns an output according to the function
Š returns a value – just like in algebra! Š data given to a function is an argument
• Used in expressions • Strings vs. Numeric functions
Š allows complex mathematics Š functions that end in $ return a string
Š allows better control of strings otherwise,, it returns a number
Š otherwise

1
Function Call Syntax Some Built
Built--in
Number Functions

Function Returns
Name of the function SIN mathematical sine
COS mathematical cosine
Name ( Arguments ) RND random number between 0 and 0.99...
INT integer (no decimal values)
Zero or more
VAL value of a string (convert)

Number Review Number Review


Output

DIM Value 45.123


LET Value = 45.123
PRINT Value

INT() Example INT() Example


Output

DIM Value 45
LET Value = 45.123 Decimal value
removed
PRINT INT(Value)

2
COS() Example COS() Example
Output

DIM X Number Cosine


LET X = 6
6 0.96071
PRINT "Number", "Cosine"
PRINT X, COS(X)

VAL() Example VAL() Example


Output

DIM Text AS String 106


Result is a
number
LET Text = "100"
PRINT VAL(Text) + 6

Some Built
Built--in String Review
String Functions

Function Returns
LTRIM$ left spaces trimmed (removed) DIM User AS String
MID$ middle part of the string (substring)
LCASE$ string in lowercase LET User = "Joe Gunchy"
UCASE$ the string in uppercase
PRINT User
STR$ string for a number (convert)

3
String Review UCASE$() Example
Output

Joe Gunchy DIM User AS String

LET User = "Joe Gunchy"


PRINT UCASE$(User)

UCASE$() Example LTRIM$() Example


Output

DIM Text AS STRING


JOE GUNCHY Some spaces

LET Text = " Hello"


PRINT Text
PRINT LTRIM$(Text)

LTRIM$() Example Multiple Function


Output Example

DIM Text AS STRING


Hello
Hello LET Text = " Hello"
Poof! The function
PRINT Text
removed them PRINT UCASE$(LTRIM$(Text))

4
Multiple Function
Example Output

Hello QBasic Lab


HELLO
LTRIM$ and UCASE$
Functions – Space Cadet

Lab: Space Cadet

• Objectives
Š use variables
Š use built-
built-in functions
• Your Program
Š calculate how much fuel your ship needs
Š calculate the perimeter of a polygon Your flight plan
inscribed inside a circle

Celestial Bodies Remember ...

• Azeroth
• Grue
• LV
LV--426
• Maximegalon
• Turn your program & your output
• Marklar Š Lab 4 in SacCT
• Spaceball
• Yugopotamia
• Vogsphere

5
Essay
Project

The G.E. Writing Requirement

Remember...

• Do not plagiarize ...


Š Do not copy text from
fromanother
another paper
Š Do not submit someone else's paper
Š Do not falsify or invent sources
• If you cheat ...
Š You will receive an "F" in this class
Š You could also be expelled

What is a Network?

Network • Computers that are connected


Š able "talk"
talk to each other
Basics Š able exchange data
• They can be connected:
Š using ports and wires
Š radio waves
What is a Network? Š etc....

6
Networking Network
Advantages Disadvantages

• Share Data • More vulnerable to unauthorized access


Š examples: files,
files ee--mail,
mail, pictures,...
pictures Š data theft – the wrong people get data
• Share Devices Š hacking – someone attacks your computer
Š examples: printers, scanners, ... • More vulnerable to malicious code
• Work together Š worms
Š regardless of time and place Š viruses
Š examples: instant messaging, virtual meetings Š etc....

Geographic Scope Bandwidth

• Bandwidth
• Personal Area Network Small Š capacity of a communications channel
• Local Area Network • High
High--bandwidth systems
• Neighborhood Area Network Š sometimes referred to as broadband
Š excellent for transmitting multimedia
• Metropolitan Area Network
Large • Low
Low--bandwidth systems
• Wide Area Network Š sometimes referred to as narrowband

Network Links

• Wired network
Š data travels between devices over a cable
• Wireless network
Š data travels between devices through radio waves
in the air
• Communication channels
Š physical path or a frequency
Š e.g. computer cables, cell phone frequency

7
What is a Protocol?

Communication • Set of rules that define


Š how
h data
d t iis sentt
Protocols Š rules for sending
Š how computers "talk"

• Format
How Computers Talk Š how data is transmitted

Protocol Layers London Bridge is


Falling Down ...

• London Bridge
• Application Layer
Š commuter bridge constructed in 1831
• Transport Layer Š don't confuse it with the London's Tower Bridge

• Network Layer • By 1924 ...


Š London Bridge was falling down
• Data Link Layer
Š it was also sinking in the clay
• Physical Layer • The British decided to build a new bridge

8
London Bridge is London Bridge is
Falling Down ... Moving 'round
• Robert P. McCulloch
• Break the bridge into pieces
Š businessman
Š since the bridge is masonry
Š bought London Bridge Š “bricks” was the logical choice
Š decided to move it to Lake • Each was labeled carefully
Havasu City, Arizona, and Š the span it was in - 5 total
rebuilt it in 1971 Š the row of stone it was in
• How do you move a bridge? Š its position in the row

London Bridge is London Bridge is


Moving 'round Homeward Bound

• The bricks were put into crates • The crates


• Each crate was carefully Š stuff arrived at different times
labeled Š and took different routes
• Crates were transported • Since each was organized
Š moved by ship to the East Coast Š the bridge could be reconstructed
Š then, trucked to Arizona Š now, London Bridge is in Arizona

Application Layer

• The "Bridge
g Structure"
• Top
Top--most layer
• Protocol depends on the application
Š what type of data is being sent
Š what extra information is needed

9
Transport Layer Network Layer

• The "Crates of Bricks" • The "Crate Mailing


g Addresses"
• The units that pass over a network • Each computer has a unique address
Š the "crates" are called packets Š contains a Source and Destination
Š different networks use different formats Š allows packets to be “mailed” to the target

• The Internet uses TCP (transmission control protocol) • The Internet uses IP (internet protocol)

Data Link Layer Physical Layer

• The "Shipping Department" • The "Boats and Trucks"


• Determines • The physical way data is transferred
f
Š when data will be sent over physical devices • Examples
Š which physical devices Š wires
• Examples Š fiber optic cables
Š Ethernet, Wi
Wi--Fi, etc.... Š radio and microwave transmissions

Protocol Layer
Summary

Application Layer Bridge Structure


Transport Layer Crates of Bricks
Network Layer Mailing Address
Data link Layer Shipping Routes
Physical Layer Boats, trucks, etc...

10
What is the Internet?

• The Internet is a massive collection of networks


The Internet that are linked together
Š computers can be anywhere in the World
Š originally designed by the United States
Š designed to never go down.
• The main routes are the Internet backbone
The Mother of All Networks • Different networks communicate using TCP/IP

How the Internet Got Who Controls the


Started Internet?
• The DOD created ARPA
Š Advanced Research Projects Agency • It is not owned, operated, or controlled
Š response to the launch
la nch of Sputnik
Sp tnik in 1957 by
b any single
i l entity
tit
Š help scientists communicate
Š share valuable computer resources
• It is controlled by:
Š private businesses
• ARPANET
Š connected computers at four universities – 1969 Š United States Federal Government
(UCLA, Stanford, UCSB, and U of Utah)
(mostly management)

Network Service Internet Service


Providers Providers

• Manage and own different • Internet Service Provider


parts of the Internet Š operates network devices that handle the physical
• Network Access Points aspects of transmitting and receiving data
Š connection points between • Many ISPs
Network Service Providers Š connect the user to the Internet
Š handles a large amount of Š handle incoming and outgoing mail
traffic Š maintain web servers for subscriber Web sites

11
The Internet Uses
TCP / IP

• Provides a standard
Š refers to the Network and Transport layers
Š easy to implement and extensible
Š public and free
NAP Backbone
• TCP / IP is ...
Š the standard network and transport layers
Š allows all the networks to communicate

Transporting Data IP Addresses

• The TCP part of TCP/IP defines • The IP part of TCP/IP defines


Š Internet Protocol
Š Transmission Control Protocol Š format of addresses that identify individual computers
Š how data will be bundled to be transported Š analogous to the "crate mail addresses"
Š analogous to the ""crates
crates of bricks" • Internet Addresses - IP Address
Š series of numbers, such as 130.86.129.1
• Allows information to be moved over Š Internet Protocol (IPv4) - Only 4 billion
different networks Š IPv6 is needed - 3.4 × 1038

Domain Names Looking up Domain


Names

• IP Addresses are not friendly • Each domain corresponds to an IP address


Š 130.86.129.1 is www.csus.edu • Domain Name System
Š who is going to remember these? Š huge database that stores names & IP addresses
• Fully Qualified Domain Name Š browser "looks up" the IP address from the name
Š usually typed in all lowercase Š this is called DNS Lookup

Š used by websites & e e--mail • Domain Name Servers house the database

12
Top Level Domains Open Top Level
(TLD) Domains

• Usually the last three characters .biz Commercial Business


Š used to describe the type of domain
Š examples: .edu, .com, .org .com Commercial Business
• Controlled by .info Information
Š Internet Corporation for Assigned
Names and Numbers (ICANN
(ICANN)) .net Network - Open
Š contracted with the U.S.
Š new ones are being created .org Non-Profit Organization

Restricted Top Level World State Top Level


Domains Domains

.edu Educational Institutions .ca Canada


.gov United States Government .cn China
.int International Organizations .br Brazil
.mil United States Military .gr Greece
.pro Licensed Professionals .in India

World State Top Level World State Top Level


Domains Domains

.ie Ireland .il Israel


.eu European Union .jp Japan
.kr South Korea .mx Mexico
.pk Pakistan .ru Russia
.se Sweden .uk Britain (United Kingdom)

13
ICANN Now Allows
Custom TLDs!

• On July 24, 2008, ICANN ....


Š voted to allowany
allow any top level domain
Š can be bought like regular domain names
Š .com,
.com, .org,
.org, etc... are public
• New top-
top-level domain can act is hub
Š Apple could get .mac – mail.mac, store.mac, etc...
Š Myspace could get .myspace
Š etc...

14

You might also like