-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntroduction to Python
More file actions
50 lines (37 loc) · 1.33 KB
/
Copy pathIntroduction to Python
File metadata and controls
50 lines (37 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Introduction to Python
# Python: A versatile programming language created by Guido van Rossum, first released in 1991.
# Hello World Program
print("Hello, World!")
# Checking Python Installation and Version
# Command-line:
# python --version
# Running Python in Command Line
# Command-line:
# python
# exit()
# Creating a Python File
# Python code typically resides in files with a .py extension.
# Example: Create a file named sample.py and add Python code to it.
# Variables in Python
# Variables store data. Unlike some languages, Python doesn't require declaring the data type explicitly.
x = 'Hello World' # Example: Assigning a string to a variable named x
# Comments in Python
# Use # for single-line comments and ''' ''' for multi-line comments.
# Data Types
# Python supports various data types:
# - Integers: Whole numbers.
# - Floats: Numbers with decimal points.
# - Strings: Text, enclosed in single (' ') or double (" ") quotes.
# - Booleans: True or False values, used for logical operations.
# Examples of Data Types:
age = 30 # Integer
height = 5.3 # Float
name = "Ana" # String
is_python_fun = True # Boolean
# Printing Variables
# Use print() to display the value of variables.
print(x) # Output: Hello World
print(age) # Output: 30
print(height) # Output: 5.3
print(name) # Output: Ana
print(is_python_fun) # Output: True