Computer and Program • a Computer Is an Electronic Machine That Is Used to Store, Retrieve, and Process Data Under the Control of Set of Instructions Called Program

Computer and Program • a Computer Is an Electronic Machine That Is Used to Store, Retrieve, and Process Data Under the Control of Set of Instructions Called Program

Computer and Program • A computer is an electronic machine that is used to store, retrieve, and process data under the control of set of instructions called program. • The set of instructions to the computer hardware is called program or software. • There are many programming languages invented to write programs. For example: Python, Java, C, C++, HTML, CSS etc. @pearahmedbhuiyan What is Python? • Python is a programming language in order to write a program. • It was written by Guido van Rossum and released in 1991. • The latest version of Python is Python 3.8.3 • Python works on different platforms such as Windows, Mac, Linux, Raspberry Pi, etc. @pearahmedbhuiyan What can Python do? • Python is a programming language used to write a computer program (software). • It can be used for but not limited to the following: – Connecting to database to use data in a program. – Reading from, writing to and modifying an external file. – Handling huge data and complex mathematical computations. – Writing server side programming in web applications (software). @pearahmedbhuiyan Python Syntax compared to Other Languages • Like human language computer programming language follows certain grammar (rules) which is called Syntax. • Python has a simple syntax somewhat similar to English language with some influence from mathematics. • Python has syntax that allows programmers or developers to write programs with fewer lines than some other programming languages. • Python runs on an interpreter which means that code can be executed as soon as it is written. @pearahmedbhuiyan Python Syntax compared to Other Languages • Python uses new lines to complete a command or single statement whereas other programming languages often use semicolons. • Python relies on indentation, using whitespace, to define a block of statements. Other programming languages often use curly- brackets for this purpose. @pearahmedbhuiyan Python Installation • Many PCs and Macs will have python already installed. • To check whether python has already been installed on a Windows PC: -search in the start bar for Python or run the following command on the Command Line (cmd.exe): C:\users\your computer name>python --version • To check on Mac PC open the terminal and run: python --version • On Linux open the command line and run: python --version @pearahmedbhuiyan Integrated Development Environment (IDE) • An Integrated Development Environment (IDE) is a software that provides with good environment to develop a software. • Software developers use different tools throughout the development of a software like text editors, code libraries, compilers and test platforms. • An IDE provides with many of these tools together as a single framework , a suite or service. • An IDE simplifies software development and minimize coding mistakes and typos. • Most popular IDE tools include Eclipse, NetBeans, Microsoft’s Visual Studio etc. @pearahmedbhuiyan Integrated Development Environment (IDE) • You can write Python program in a Text Editor or in an Integrated Development Environment, such as Thonny, Pycharm, Netbeans or Eclipse. • In the class you will be writing Python programs on an online IDE named Repl.it whose web address is https://repl.it • On the web browser address bar enter the address https://repl.it press enter or search by writing repl.it and click the link of repl.it. The Repl.it will open. @pearahmedbhuiyan Repl.it @pearahmedbhuiyan Repl.it @pearahmedbhuiyan Repl.it • You can click <start coding> and choose the programming language Python to start writing a program in Python. • There is a sign in option before clicking <start coding>. You need to sign up in order to sign in. • Sign up once and sign in to keep your program files for using next time. @pearahmedbhuiyan Choose (click) Python After Signing In Repl.it @pearahmedbhuiyan After Choosing (Clicking) Python @pearahmedbhuiyan Repl.it Window • There are three rectangular areas in the repl.it window. – The middle one is to write the program. – The right one is to see the output of the program when it is run. – The left one for different tasks such as exploring files, adding files and folders, uploading files etc. There is a Run button above the rectangular areas that you click to run the program. @pearahmedbhuiyan First Python Program @pearahmedbhuiyan Print() Function • The print() function prints the specified message to the screen or other standard output device. • The message can be a string or any other object which is converted into a string before written to the screen. • The message is written inside the parenthesis of the print() function. @pearahmedbhuiyan Printing a string using double quotes @pearahmedbhuiyan Printing a string using single quotes @pearahmedbhuiyan Escape Characters • Use an escape character to insert a character that is illegal in a string. • An escape character is a backslash \ followed by the character you want to insert. • String with single or double quote can not be enclosed inside the same quote. It can be done with escape sequence character. For example: “This is \“Orchid\” flower”. Here \” is called escape sequence character. @pearahmedbhuiyan Using Escape Sequence @pearahmedbhuiyan Some Escape Characters Code Result \’ ‘ \” ” \\ \ \n Moves to new line \t Keeps space of tab @pearahmedbhuiyan In Class Exercise Read the handout and then write the answers of the following questions in your own words. 1. What is Python? 2. What can Python do? @pearahmedbhuiyan In Class Exercise Open the repl.it IDE on your browser and write the following programs: 3. Write print() commands to print five lines of text describing about Python and show the output. 4. Write a program to print the following: I like Programming. There are many programming languages such as Python, Java, C, C++ etc. The syntax of Python is simpler than other programming languages. @pearahmedbhuiyan In Class Exercise 5. Write a program to output (display) at least five lines about IDE to the screen. 6. Write a program that will print text (string) describing five advantages of Python compared to other programming languages. 7. Write a program to display the following: I like fruits specially Apple, Orange and Cherry. I am going to buy some fruits tomorrow. I am not sure which store I should go. Do you have any suggestions. @pearahmedbhuiyan In Class Exercise 8. Write a python program to print the following: I like ice cream. How do you like a “Toyota” car? Do you like ‘Python’ programming? My favorite fruits are: ‘Mango’, ‘Banana’ and ‘Pine Apple’. Student ID Name Mark 101 James 90 @pearahmedbhuiyan Homework 1. Write in your own words at least three characteristics of Python Syntax compared to other programming languages 2. Write a program that describes about Python by printing at least seven lines of text. 3. Write a program that will display text describing the syntax of Python. 4. Write a program that will output text describing about repl.it. Homework 5. Write a program with comments to display the following: I like shopping. Today I am going to buy some fruits specially “Orange”, “Guava” and “Strawberry”. Tomorrow I am going to ‘Bayview village’. ID First Name Last Name 101 John Edward.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    27 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us