MITX:6.00.1X Introduction to Computer science and Python programming WEEK-01

Source: Internet
Author: User
Tags scalar

** * * * WEEK-01 * * * * *

    • Lecture1 Introduction to Computation:
      1. Algorithm is recipes.
      2. An algorithm is a conceptual(concept) idea , a program is a concrete instantiation(instantiated) of an algorithm.
      3. The embryonic form of modern computers: Stored program computer
      4. Basic Primitives: # operating system terminology category. A process consisting of several directives that are used to accomplish a certain function.
5. Programming Language:
Each
programming Language provides a set of p Rimitive operations.
each Programming language provides mechanisms for combining P rimitive s to form More Complex, but Legal, expressions.
Each
programming language provides mechanisms for deducingmeanings or values associated with computations   or expressions.
6.
       
7.
                        
    • Lecture2 Core Elements of Programs:
      1. Python is an interpreted language that is a little slower than a compiled language. On the other hand, once we encounter errors or vulnerabilities, it is often easier to find the place that caused the error.
      2. There are three types of scalar object in Python: Int,float,bool.
      3. Remember This in Python words is case-sensitive (case sensitive). The word true is a Python keyword (it's the value of the Boolean type) and is not the same as the word true.
      4. Priority: Round brackets, not,and,or.
      5. Round (2.6), 3.0; Int (2.6), 2; 5*2 = = 5.0 * 2.0->true
      6. Non-scalar object: /* Note and Java similar to "ABCD" [0:2] such a drop mark from 0 to subscript 1 (2-1=1) * /
# and Abcd[-1] can also be labeled as 0-3-2-1, so the result is D# ' Hello ' = = ' Hello '->false# Str4[1:9:2] string slice (slice) position from 1 to 9-1 (i.e. 8), step 2, which is the substring with index value 1,3,5,7 (note index value starting from 0) STR4 = ' HelloWorld ' STR4 [1:9:2] = ' elwr ' # Str4[::-1] simply reverse the string!!! Step-1, means backwards from the back. And each step is 1, if-2 is backwards and the interval is 2.

there ' s one other cool thing you can does with string slicing. You can add a third parameter,k, like this:s[i:j:k]. This gives a slice of the stringsFrom indexiTo indexj-1 , with step size k. Check out the following examples:

>>> s = ' Python is fun! '
>>> S[1:12:2]
' Yhni u '
>>> S[1:12:3]
' Yoif '
>>> S[::2]
' Pto sFn '

The last example was similar to the examples[:]. withs[::2], we ' re asking for the full strings(from index 0 through), with a step size of 2-so we end up with every and other character ins. Pretty cool!

 
7. About the use of function raw_input () . 8. Write a comment in the back of #. 9.   Indentation represents a block of instructions, which is a little different from the Java,c language. 10.   Compare different types of variable sizes: 11. elif equivalent to else if, if the colon cannot be omitted after the sentence is finished!
         
A. Type function:
1 if or type (VarA) ==str:  # The type function is used here, and STR int bool can write 2     print( ' string involved ')

MITX:6.00.1X Introduction to Computer science and Python programming WEEK-01

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.