0% found this document useful (0 votes)
3 views2 pages

Python Basics Summary

The document provides an overview of Python basics, covering keywords, identifiers, variables, and data types. It explains operators, input/output functions, type conversion, and details on data structures such as strings, lists, tuples, dictionaries, and sets. Each section includes syntax examples and key characteristics of the concepts discussed.

Uploaded by

pcmc2cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Python Basics Summary

The document provides an overview of Python basics, covering keywords, identifiers, variables, and data types. It explains operators, input/output functions, type conversion, and details on data structures such as strings, lists, tuples, dictionaries, and sets. Each section includes syntax examples and key characteristics of the concepts discussed.

Uploaded by

pcmc2cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Basics Summary

1. Keywords and Identifiers

Keywords are reserved words used by Python to define the syntax. Examples: if, else, while, def.

Identifiers are names for variables, functions, classes, etc. They cannot start with a digit or use special

characters.

2. Variables and Datatypes

Variables store data values. Python datatypes include:

- int: Integer numbers

- float: Decimal numbers

- str: Text

- list: Mutable sequence

- tuple: Immutable sequence

- set: Unordered, unique items

- dict: Key-value pairs

- None: Represents no value

3. Python Operators

- Arithmetic: +, -, *, /, //, %, **

- Comparison: ==, !=, <, >, <=, >=

- Logical: and, or, not

- Assignment: =, +=, -=, *=, /=

4. Input/Output

Use input() to take user input and print() to display output.

Example: name = input('Enter name: ')

5. Type Conversion

Implicit: Python auto-converts types.

Explicit: Use int(), float(), str(), etc. to convert between types.


Python Basics Summary

6. Strings

Strings are ordered sequences of characters. Enclosed in single or double quotes. Supports indexing, slicing,

and methods like .upper(), .lower(), .replace().

7. Lists

Lists are mutable, ordered collections. Syntax: [1, 2, 3]

Methods: append(), insert(), remove(), pop(), extend(), sort(), reverse().

8. Tuples

Tuples are immutable, ordered collections. Syntax: (1, 2, 3)

Use indexing to access elements. Cannot modify after creation.

9. Dictionaries

Dictionaries are unordered collections of key-value pairs. Syntax: {key: value}

Access with keys, e.g., d['name'] = 'John'.

10. Sets

Sets are unordered collections with no duplicate items. Syntax: {1, 2, 3}

Support set operations like union, intersection, difference.

You might also like