comprog

Cards (31)

  • Python is a high-level programming language. Open source and community driven. Source can be compiled or run just-in-time. Similar to perl, tcl, ruby
  • Python
    • Unlike AML and Avenue, there is a considerable base of developers already using the language
    • "Tried and true" language that has been in development since 1991
    • Can interface with the Component Object Model (COM) used by Windows
    • Can interface with Open Source GIS toolsets
    • It has simplified syntax and not complicated, which gives more emphasis on natural language
  • PYTHON PRINT STATEMENT
    • print("Hello World")
  • IDE
    An integrated development environment (IDE) is a software application that provides comprehensive facilities for software development
  • IDE
    • OnlineGDB.com
    • PyCharm
    • Pydroid 3
  • IDLE
    • Helps you program in Python by color-coding your program code, debugging, auto-indent, interactive shell
  • Syntax and Rules in Python
    • The standard is to use English names in programming
    • Python is case-sensitive, which means, for example, Name and name have different meanings
    • The first letter of a variable, function, or class must be one of the letters (a-z) or (A-Z). Numbers or special characters such as & and% are not allowed
    • Python is sensitive to indentations, that marks a block segment in your code
    • Functions begin with lowercase
    • Classes begins with a capital letter
    • There are reserved words, such as and, if, else, break, import, and more, which are not allowed in naming variables
  • Data type in python
    Represents the data store in memory or variable
  • Data types in Python
    • Built-In Data Types
    • User-Defined Data Types
  • Built-In Data Types
    • Numbers
    • String
    • Tuple
    • List
    • Set
    • Dictionary
  • Numbers
    The Number data type is used to stores numeric values
  • String
    The string data type is used to stores the sequence of characters
  • Tuple
    Tuple data type is used to stores a collection of different data types of elements, and it is immutable
  • List
    List data type is used to store the collection of different data types of elements, and it is mutable
  • Set
    Set data type is used to store different data types of elements; it is mutable and stores unique elements
  • Dictionary
    Dictionary data type is used to store a collection of different data types of elements in the form of key-value pairs; it is mutable and stores the unique key
  • Numeric Python Data Types
    • int
    • float
    • complex
  • int
    To store integer values
  • float
    To store decimal values
  • complex
    To store complex numbers (real and imaginary part)
  • Sequence Python Data Types
    • String
    • Lists
    • Tuple
  • String
    In Python, the text data type is called "string" and is abbreviated as str. Using a string data type means that everything is treated as text, even the numbers.
  • Lists
    are just like the arrays, declared in other languages which is a ordered collection of data. It is very flexible as the items in a list do not need to be of the same type.
  • Tuple
    Just like list, tuple is also an ordered collection of Python objects. The only difference between tuple and list is that tuples are immutable i.e. tuples cannot be modified after it is created.
  • Other Python Data Types
    • Dictionary
    • Set
  • Dictionary
    Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair.
  • Set
    In Python, Set is an unordered collection of data type that is iterable, mutable and has no duplicate elements. The order of elements in a set is undefined though it may consist of various elements.
  • Boolean data type

    A Boolean data type is a value that can only be either true or false (these are known as Boolean values).
  • A true Boolean value might indicate that the object is valid (e.g. an email address has been typed correctly). A false Boolean value indicates that the object is invalid and has not been done correctly (e.g. you've forgotten to fill out a required field).
  • Problem 1: Integer and Float Operations
    1. Declare two variables, num1 and num2, with values 10 and 5.5 respectively
    2. Calculate the sum, difference, product, and quotient of these two numbers
    3. Print the results in a formatted manner
  • Problem 2: String Manipulation
    1. Declare a string variable name with your name
    2. Declare another string variable country with the name of your country
    3. Concatenate the two strings and store the result in a variable message
    4. Print the message variable