1 / 91

Computer Science 1 Week 13

Computer Science 1 Week 13. This Week. QBasic Data Files Computer History PC Revolution Graphical User Interface. QBasic Data Files. Saving and retrieving data from a file. Input Data. Store Data. Output Data. Functions of a Computer. QBasic Data Files.

madge
Download Presentation

Computer Science 1 Week 13

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Science 1Week 13

  2. This Week ... • QBasic Data Files • Computer History • PC Revolution • Graphical User Interface

  3. QBasic Data Files Saving and retrieving data from a file

  4. Input Data Store Data Output Data Functions of a Computer

  5. QBasic Data Files • QBasic Lite data files are text files • other languages support more complex formats • you can create files with any text editor • e.g. Windows Notepad • Text format: • Data items are separated by commas • ornew lines

  6. Example Data File ENIAC,First Generation,1946 The Same ENIAC First Generation 1946

  7. Open Statement • Opens a file • must be done first! • referenced by file numbers • Access Modes • Input – read data from a file • Output – write data to a file

  8. Optional Open Statement Syntax OPEN File FOR INPUT AS # Num OPEN File FOR OUTPUT AS # Num

  9. Minimal SyntaxInput Mode OPEN File AS # Num

  10. Open Example OPEN "test.txt" FOR INPUT AS #1 Input Mode Text File File Number

  11. Open Statement – Finding the Data File • If a path is not used in the Open Statement • QBasic looks in the same folder as your program • if you haven't saved your program – it can't find the data file! • So, make sure to: • save your program first • put the data file in the same folder

  12. Close # Statement • Closes a file • which was opened previously • all open files should be closed • QBasic • automatically closes files when the the program finishes • it is still a good idea to use close

  13. Input # Statement • Reads data from a file • first opened AS INPUT • if not, an error occurs • Assigns it to a variable • works like the normal input statement • reads as many values as variables

  14. Input # Statement Syntax INPUT # Num, Variables # used with Open 1 or more

  15. Example Program DIM Person as string DIM Age as integer DIM Greek as string OPEN "Name.txt" FOR INPUT AS #1 INPUT #1, Person, Age, Greek PRINT Person; " pledged "; Greek CLOSE #1 Name.txt Herky,22,Tappa Kegga Bru

  16. Example Output Herky pledged Tappa Kegga Bru

  17. EOF Function • Acronym for end of file • Used with a file opened for input • used to read a whole file • often used with a While Loop • Returns True when ... • the end is reached • also True if the file is not open

  18. EOF Function Example OPEN "Test.txt" AS #1 DO WHILE NOT EOF(1) INPUT #1, Num PRINT "Read:"; Num LOOP CLOSE #1

  19. EOF Function Example DO WHILE NOT EOF(1) INPUT #1, Num PRINT "Read:"; Num LOOP File Screen 111 222 Read: 111 Read: 222

  20. EOF Function Example 2 DO WHILE NOT EOF(1) INPUT #1, Number LET Total = Total + Number LOOP PRINT "The total is:"; Total Running Total

  21. EOF Function Example 2 Output 90,85,71,77,63,84,98,80 The total is 648

  22. DO WHILE NOT EOF(1) INPUT #1, Number LET Total = Total + Number LET Count = Count + 1 LOOP PRINT "Count:"; Count PRINT "Average:"; Total / Count Running Total Item count File: 90,85,71,77,63,84,98,80

  23. EOF Function Example 3 Output 90,85,71,77,63,84,98,80 Count: 8 Average: 81

  24. Write # Statement • Writes data to a file • opened AS OUTPUT • if not, an error occurs • Often used with INPUT # • saves data in the format Input # can read • data items are separated by commas

  25. Write # Statement Syntax WRITE # Num, Items # used with Open 1 or more

  26. Write # Example OPEN "out.txt" FOR OUTPUT AS #1 WRITE #1, "Herky",22,"TKB" CLOSE #1 Herky,22,TKB

  27. Print # Statement • Prints data to a file • opened AS OUTPUT • if not, an error occurs • Identical to normal print • semicolons append data • commas print in different "columns" • Best used for "printout" files

  28. Print # Statement Syntax PRINT # Num, Items # used with Open 1 or more

  29. Print # Example OPEN "out.txt" FOR OUTPUT AS #1 PRINT #1, "Herky",22,"TKB" CLOSE #1 Herky 22 TKB

  30. QBasic Lab This Week's Exercise

  31. Completely Census Lab • Overview • you are Herman Hollerith • It’s census time! • You will: • read actual 2000 Census data! • compute the U.S. population

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

  33. 4th Generation Computers Computer History

  34. Fourth Generation Computers • 1971 to present • Use the microprocessor • "a computer on a chip" • faster, smaller & low cost • examples: Intel & Motorola processors • Gave rise to the PC Revolution

  35. 6502 Processor

  36. Moore’s Law • Moore's law describes a long-term trend in the history of computing hardware. The number of transistors that can be placed inexpensively on an integrated circuit doubles approximately every two years. This trend has continued for more than half a century and is expected to continue until 2015 or 2020 or later

  37. Moore’s Law (contd.) • The capabilities of many digital electronic devices are strongly linked to Moore's law: processing speed, memory capacity, sensors and even the number and size of pixels in digital cameras. All of these are improving at (roughly) exponential rates as well. • This exponential improvement has dramatically enhanced the impact of digital electronics in nearly every segment of the world economy. Moore's law describes a driving force of technological and social change in the late 20th and early 21st centuries.

  38. Moore’s Law (contd.) • The law is named after Intel co-founder Gordon E. Moore, who described the trend in his 1965 paper. The paper noted that the number of components in integrated circuits had doubled every year from the invention of the integrated circuit in 1958 until 1965 and predicted that the trend would continue "for at least ten years". • His prediction has proved to be uncannily accurate, in part because the law is now used in the semiconductor industry to guide long-term planning and to set targets for research and development

  39. Graphical User Interface Computer History

  40. Xerox Alto • Palo Alto Research Center (PARC) • one of the most famous research groups ever • developed the GUI, laser printers, SmallTalk • First built in 1973 • Prototype – never sold • some were given to universities – we have one! • graphic user interface • worked with input devices – mouse, keyset

  41. Mouse Keyset

  42. Maze War

  43. Xerox Star 8010 • First commercial GUI system • very little has changed in GUI design • released in 1981 • Major GUI Features • set the basic metaphors still used today • What You See Is What You Get • monochrome graphics

  44. Xerox Star 8010 • Sold for $16,000 each! • not designed to be stand-alone system • sold in groups for offices • Demonstrated in 1979 to: • Steve Jobs – began work on Lisa • Bill Gates – began work on Windows • inspired many other systems

More Related