Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science 1 Week 12. This Week... QBasic For Loops QBasic For Loops Computer History Computer History  1 st – 3 rd Generation computers Website.

Similar presentations


Presentation on theme: "Computer Science 1 Week 12. This Week... QBasic For Loops QBasic For Loops Computer History Computer History  1 st – 3 rd Generation computers Website."— Presentation transcript:

1 Computer Science 1 Week 12

2 This Week... QBasic For Loops QBasic For Loops Computer History Computer History  1 st – 3 rd Generation computers Website Project is Due! Website Project is Due!

3

4 QBasic For Loops Looping a variable through a range

5 For Statement Loops a block of statements Loops a block of statements  the block is executed numerous times  this allows you to create repetition When do you use it? When do you use it?  execute a block a number of times  process data using the set of numbers Very versatile in QBasic Lite Very versatile in QBasic Lite

6 For Statement Uses a numeric variable Uses a numeric variable  starts with an initial value  changes its value for each loop  stops once its value is greater than end value Semantics... Semantics...  assigns the initial/next value to the variable  executes the block if the variable is not greater than the end value  repeats the process Default: increment by one (+ 1) in each loop automatically

7 FOR variable = start TO end Statements NEXT Basic For Statement Syntax

8 FOR x = 1 to 5 PRINT x NEXT Simple Loop Example

9 1234512345 Simple Loop Example Output

10 FOR x = 1 to 5 PRINT x, x ^ 2 NEXT Simple Loop 2 Example

11 1 2 4 3 9 4 16 5 25 Simple Loop 2 Example Output

12 FOR x = -5 to -1 PRINT x, x ^ 2 NEXT Negative Values Example

13 -5 25 -4 16 -3 9 -2 4 -1 1 Negative Values Example Output

14 FOR Quiz = 1 to 3 INPUT "Score: ", Score LET Sum = Sum + Score NEXT PRINT "Average is"; Sum / 3 Average Example

15 Score: 97 Score: 72 Score: 83 Average is 84 Average Example Output

16 Inner Loops Like all QBasic blocks, you can put loops within loops Like all QBasic blocks, you can put loops within loops The loop in the inner-most block is an inner loop The loop in the inner-most block is an inner loop The loop in the outer-most block is an outer loop The loop in the outer-most block is an outer loop

17 FOR x = 10 to 11 PRINT "Outer: "; x FOR y = 1 to 2 PRINT " Inner: "; y NEXT Inner Loop Example

18 Outer: 10 Inner: 1 Inner: 2 Outer: 11 Inner: 1 Inner: 2 Inner Loop Example Output

19 FOR x = 5 to 1 PRINT x NEXT Not-So-Simple Loop Example Negative Range

20 Not-So-Simple Loop Example Output Nothing!

21 Not-So-Simple Loop Why? The For... Next Statement The For... Next Statement  starts at the first value  continues until the value of the variable is greater than the end value If the start value is greater than the end value, the loop never executes If the start value is greater than the end value, the loop never executes

22 The Step Clause Normally, the For... Next Statement increments using +1 Normally, the For... Next Statement increments using +1 The Step Clause allows you to change the increment value The Step Clause allows you to change the increment value This allows you to: This allows you to:  create negative loops  create loops that jump by a specific value

23 FOR var = start TO end STEP inc Statements NEXT Full For... Next Statement Syntax The increment is defined by the step here

24 FOR x = 1 TO 10 STEP 2 PRINT x NEXT Large Step Example The increment for variable x in each loop is 2 here

25 1357913579 Large Step Example Output

26 FOR x = 5 TO 1 STEP -1 PRINT x, x ^ 2 NEXT Negative Step Example The increment for variable x in each loop is  1 here

27 5 25 4 16 3 9 2 4 1 Negative Step Example Output

28 FOR x = 1 TO 5 STEP 0 PRINT x, x ^ 2 NEXT Zero Step Example

29 RUNTIME ERROR: Line 1 : Step value is zero Zero Step Example Output

30 While Loop vs. For Loop For Loop is a form of the While Loop For Loop is a form of the While Loop As a result: As a result:  a While Loop can implement any For Loop  the For Loop is used as a shortcut notation

31 x = 1 DO WHILE x <= 5 PRINT x LET x = x + 1 LOOP While Loop vs. For Loop FOR x = 1 TO 5 PRINT x NEXT

32 1234512345 While Loop vs. For Loop Output 1234512345

33 QBasic Lab For Loops – 99 Bottles of Something

34 Lab: 99 Bottles of Something Overview: Overview:  You will use QBasic to print the 99 Bottles of Beer (Water) Song  Use another drink, water or juice Objectives: Objectives:  Use a For Statement to print the song  Use an If Statement inside the loop

35 Remember... Turn your program & your output Turn your program & your output  to Lab10 in SacCT You must do your own work You must do your own work If you do not turn in your program, you will not get credit! If you do not turn in your program, you will not get credit!

36

37 The First Computer Computer History

38 Punched Cards Invented by Joseph-Marie Jacquard Invented by Joseph-Marie Jacquard Textile industry Textile industry  control the flow of yarn in a loom  used to create patterns Adapted to Adapted to  automatic pianos  computer data

39

40 Charles Babbage Known as the “Father of Computers” Known as the “Father of Computers” Created several calculators Created several calculators Developed the first computer Developed the first computer

41 The Difference Engine In the 1800’s In the 1800’s  log and trig tables were calculated manually  Babbage knew machines could compute these He designed the Difference Engine He designed the Difference Engine  could compute logarithmic and trigonometric data  first machine to be automatic in action  it was not finished in his lifetime

42 The Difference Engine: continued It was completed in March 2008 at the Science Museum, London 150 years after its original design, and is faithful to Babbage’s original design (1847-49). It was completed in March 2008 at the Science Museum, London 150 years after its original design, and is faithful to Babbage’s original design (1847-49). It is one of only two Babbage engines consisting of 8,000 parts in bronze, cast iron and steel. It is one of only two Babbage engines consisting of 8,000 parts in bronze, cast iron and steel. It weighs five tons and measures 11 feet long and 7 feet tall. It weighs five tons and measures 11 feet long and 7 feet tall.

43 Computer History Museum, San Jose (June, 2012)

44

45

46

47 The Analytical Engine A general-purpose calculating machine A general-purpose calculating machine He began work in 1834 He began work in 1834  he never finished it  it has never been built If built, it would have been one of the Wonders of the World If built, it would have been one of the Wonders of the World

48 The Analytical Engine Use punched cards to run calculations Use punched cards to run calculations Had all the attributes of a modern computer Had all the attributes of a modern computer  Programs – looping, branching – "Barrels"  Memory – "The Store"  Arithmetic Logic Unit – "The Mill"  Bus – "The Rack"

49 The Store The Rack The Mill Barrels

50 Ada Lovelace Mathematician Mathematician Spoke several languages Spoke several languages University of Turin lecturer University of Turin lecturer  During a nine-month period in 1842–43, Lovelace translated Italian mathematician Luigi Menabrea's memoir (to English) on Babbage's Analytical Engine. With the article, she appended a set of notes that included a method for calculating a sequence of Bernoulli numbers with the Engine.  Her method is recognized as the world’s first computer program.

51 Ada Lovelace She made extensive notes She made extensive notes  several volumes, in fact  designed several programs  this included how to calculate Bernoulli numbers World's first programmer World's first programmer

52

53 The 1890 Census Crisis Computer History

54 Census Crisis The United States Federal Constitution The United States Federal Constitution  population must be calculated - census  this must be done every 10 years  used in the House of Representatives However, the U.S. population However, the U.S. population  had grown extremely large  the people could not be counted in 10 years

55 Herman Hollerith Developed: Developed:  first automatic card-feed mechanism  enhanced card reading  the first key punch – 200 to 300 cards per hour Used electricity Used electricity

56 Herman Hollerith His system His system  was used for 1890 census  only took 9 months! Hollerith founded Hollerith founded  Tabulating Machine Company  it later became International Business Machines

57

58

59

60 Birth of Computer Science Computer History

61 Alan Turing Mathematician, logician & cryptographer Mathematician, logician & cryptographer "Father of Computer Science" "Father of Computer Science"  Highest award in Computer Science is the Turing Award  Developed Turing Machines

62 Alan Turing's Major Works Developed Turing Machines Developed Turing Machines  invented in 1937  logical model – not an actual computer  proved programming Turing Test Turing Test  artificial Intelligence  no computer has yet passed it

63 Computer Generations Computers are historically classified by their generation Computers are historically classified by their generation Each generation... Each generation...  marks a new, major, technology  changes how computers are built and/or used  their are currently four generations

64

65 1 st Generation Computers Computer History

66 First Generation Computers 1946 to 1958 1946 to 1958 Used the vacuum tube Used the vacuum tube  they consumed a lot of power  they also tended to burn out quickly Programs written in machine language Programs written in machine language Data Data  read with Punched Cards  stored with Magnetic Tape

67 Vacuum Tubes

68 Atanasoff-Berry Computer First electronic digital computer First electronic digital computer Development Development  John Atanasoff & Clifford Berry  Iowa State University  built from 1937 to 1942 Speed: 60 Hz Speed: 60 Hz

69 Atanasoff-Berry Computer Features: Features:  binary digits to represent all data  calculations using electronics  memory is separate from CPU Rebuilt in 1997 Rebuilt in 1997  cost of $350,000  it worked!

70

71 ENIAC Electronic Numerical Integrator And Computer Electronic Numerical Integrator And Computer Development Development  John Eckert and John W. Mauchly  U.S. Ballistics Research Laboratory  Needed to fight World War II – then Cold War  Compute ballistic firing tables

72 ENIAC Designed to be Turing Complete Designed to be Turing Complete Operational in February 1946 Operational in February 1946 Features Features  5 KHz (5000 Hz)  programmed by rewiring – pre 1948  based on decimal – not binary  weighed 30 tons,18 feet high, 80 feet long

73 ENIAC A tube burned out once every 2 days A tube burned out once every 2 days Retired in 1955 Retired in 1955  operational for only 9 years  estimated to have performed more calculations than all of humanity had ever done prior

74

75

76 Grace Hopper Admiral in the U.S. Navy Admiral in the U.S. Navy Worked on several projects Worked on several projects  Mark II Mainframe  COBOL Programming Language  Compilers  Standardized software testing Discovered the first "bug" Discovered the first "bug"

77

78 September 9, 1945

79 UNIVAC Universal Automatic Computer Universal Automatic Computer Released in 1951 Released in 1951 First commercial computer First commercial computer  43 were sold to government and industry  used to tabulate the census

80 UNIVAC Some features Some features  ran programs on punched cards  secondary storage: metal oxide tape  clock: 2.25 MHz Predicted the 1952 election Predicted the 1952 election  Eisenhower over Stevenson  news agencies held the results - great publicity

81

82

83 IBM RAMAC 305 Random Access Method of Accounting and Control Random Access Method of Accounting and Control Released in 1956 Released in 1956 First computer to use a hard drive First computer to use a hard drive  based on record technology  could store 5 million 7-bit characters

84

85

86

87 2 nd Generation Computers Computer History

88 Second Generation Computers 1959 to 1964 1959 to 1964 Used Transistors Used Transistors  more reliable than vacuum tubes  required less power Compilers were developed Compilers were developed Disk Storage was developed Disk Storage was developed

89 DEC PDP-1 Programmed Data Processor-1 Programmed Data Processor-1 Digital Equipment Corporation (DEC) Digital Equipment Corporation (DEC) Released 1960 Released 1960 Features Features  read data from tape  used a cathode ray tube (T.V.) to display data The first hacker computer The first hacker computer World's first digital video game: Space War World's first digital video game: Space War

90

91

92 3 rd Generation Computers Computer History

93 Third Generation Computers 1965 to 1970 1965 to 1970 Used integrated circuits Used integrated circuits  increased speed  smaller size  lower cost  even less electricity Birth of the minicomputer Birth of the minicomputer

94 IBM 360 Most expensive computer project ever Most expensive computer project ever  the "5 billion dollar gamble"  this is over 30 billion by today's dollars Released 1964 Released 1964 Breakthrough Breakthrough  architecture and implementation are different  microcode technology

95 IBM 360 It was the first platform computer It was the first platform computer  all 360 computers would be compatible  initial models: 30, 40, 50, 60, 62, and 70  peripherals could be interchanged Huge success Huge success  companies could buy the best model  companies could upgrade their systems later

96

97 DEC PDP-8 First successful commercial minicomputer First successful commercial minicomputer  released in 1965  it cost less than $20,000 Features Features  up to 32k of RAM  1 MHz – varied by model  multiple versions available

98

99


Download ppt "Computer Science 1 Week 12. This Week... QBasic For Loops QBasic For Loops Computer History Computer History  1 st – 3 rd Generation computers Website."

Similar presentations


Ads by Google