** * * * WEEK-01 * * * * *
- Lecture1 Introduction to Computation:
- Algorithm is recipes.
- An algorithm is a conceptual(concept) idea , a program is a concrete instantiation(instantiated) of an algorithm.
- The embryonic form of modern computers: Stored program computer
- 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:
- 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.
- There are three types of scalar object in Python: Int,float,bool.
- 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.
- Priority: Round brackets, not,and,or.
- Round (2.6), 3.0; Int (2.6), 2; 5*2 = = 5.0 * 2.0->true
- 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 strings
From indexi
To 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