CIS150 Week 2: Fundamentals of Python Programming and Variab…

Python Programming and Variable Types

Introduction to Python Programming

Python is a high-level, interpreted, and general-purpose programming language developed by Guido van Rossum in 1991. It is known for its simple and readable syntax, making it easy for beginners to learn. Python is widely used in web development, data science, artificial intelligence, automation, and many other fields.

Features of Python

Easy to learn and use due to simple syntax

Interpreted language (no need for compilation)

Platform independent (runs on Windows, Linux, macOS)

Large standard library support

Dynamically typed language

Supports multiple programming paradigms

Variables in Python

A variable is a container used to store data values. In Python, variables are created when a value is assigned.

Example:

x = 10

name = “Vishal”

Rules for Naming Variables

Must start with a letter or underscore

Cannot start with a number

Cannot use keywords

Case-sensitive

Types of Variables in Python

Integer (int)

Stores whole numbers.

Example:

a = 10

b = -5

Float (float)

Stores decimal numbers.

Example:

pi = 3.14

String (str)

Stores text data.

Example:

name = “Python”

Boolean (bool)

Stores True or False values.

Example:

is_valid = True

List

Stores multiple values in a single variable.

Example:

numbers = [1, 2, 3, 4]

Tuple

Similar to list but immutable.

Example:

coordinates = (10, 20)

Dictionary (dict)

Stores data in key-value pairs.

Example:

student = {“name”: “Vishal”, “age”: 20}

Set

Stores unique elements.

Example:

unique_numbers = {1, 2, 3}

Type Checking in Python

You can check the type of a variable using the type() function.

Example:

x = 10

print(type(x))

Conclusion

Python is a powerful and easy-to-learn programming language. Understanding variables and their types is essential for writing efficient programs. Its simplicity and wide range of applications make it one of the most popular languages today.

WRITE MY PAPER

Comments

Leave a Reply