Docsity

Python Programming: Exploring the Fundamentals, Summaries of Computer Fundamentals

Partial preview of the text

Download Python Programming: Exploring the Fundamentals and more Summaries Computer Fundamentals in PDF only on Docsity!

Python Programming

Definition

 Python is an interpreted, object-oriented, high-level programming

language that is widely used in various fields including data science,

web development and artificial intelligence(AI).

Features Of Python

  • (^) Free and Open Source
  • (^) Portable language
  • (^) Interpreted Language
  • (^) GUI Programming Support
  • (^) High-Level Language

Application of Python

  • (^) Web Development
  • (^) Machine Learning and Artificial Intelligence
  • (^) Data Science
  • (^) Game Development
  • (^) Audio and Visual Application
  • (^) Software Development

Interactive mode

  • (^) Interactive mode allows you to run Python commands individually in a shell or a Python prompt. The Python shell is invoked by typing python or python3 in your terminal or command line without specifying a script.
  • (^) When you enter interactive mode, you can type Python expressions, and the interpreter immediately executes them and gives feedback.
  • (^) Example – $ python

print("Hello, World!") Hello, World!

DataTypes Numeric Sequence Mapping Set Boolean Int, Float, Complex String, List, Tuples Dictionary (^) Set Bool

Sequence (String)

Code: String1 = 'Welcome to the Geeks World’ print("String with the use of Single Quotes: ") print(String1)print(type(String1))

Sequence(List)

Code:

List = []

print("Initial blank List: ")

print(List)

List = ['GeeksForGeeks’]

print("\nList with the use of String: ")

print(List)List = ["Geeks", "For", "Geeks"]

print("\nList containing multiple values: ")

print(List[0])

print(List[2])

List = [['Geeks', 'For'], ['Geeks’]]

print("\nMulti-Dimensional List: ")

print(List)

Boolean

Code: a = True Print(type(a)) b = False Print(type(b))

Set

Code: set1 = set() print("Initial blank Set: ") print(set1) set1 = set("GeeksForGeeks") print("\nSet with the use of String: ") print(set1) set1 = set(["Geeks", "For", "Geeks"]) print("\nSet with the use of List: ") print(set1)set1 = set([1, 2, 'Geeks', 4, 'For', 6, 'Geeks’]) print("\nSet with the use of Mixed Values") print(set1)

Recap….

Types Description Example Numeric Represents numerical values ‘int’, ‘float’, ‘complex’ Sequence Represents a collection of ordered and indexed value and sequence of Characters ‘str’, ‘list’, ‘tuple’ Set Represents a collection of unique elements ‘set’ Boolean Represents a binary truth value ‘bool’ Mapping Represents a collection of key-value pairs ‘dict’

Operators Arithmetic Assignment Comparison Logical Bitwise Identity Membership

Code:

x= y= print(x+y) print(x-y) print(x * y) print(x/y) print(x % y) print(x**y) print(x//y)

Precedence & Associativity

Operators Associativity () Left to Right ** Right to Left +x and -x Left to Right *,/,// and % Left to Right

  • and - Left to Right