Path: blob/master/Python Essentials/Python_basics-1.ipynb
3603 views
Python Basics - Part 1
Welcome to Python Basics. In this notebook, we will learn some fundamental concepts of Python programming. Introduction Python is a popular, high-level programming language known for its simplicity and readability. It is widely used in web development, data analysis, artificial intelligence, scientific computing, and more.
Variables and Print Statement
Variables are used to store information. In Python, you don't need to declare the type explicitly. The print()
function is used to display output.
type() : use to check class of a declared variable
Cell In[7], line 1
1_a="ashi"
^
SyntaxError: invalid decimal literal
Placeholder Formatting in Print Statements
You can format strings using f-strings or the format() method.
Numbers and Operations
Python supports different types of numbers: integers, floats, and complex numbers.
You can perform operations such as addition, subtraction, multiplication, and division.
Binary Operations
Binary operations are performed on numbers at the bit level.
AND (
&
)OR (
|
)XOR (
^
)NOT (
~
)Shift Left (
<<
)Shift Right (
>>
)
000-0 001-1 010-2 011-3 100-4 101-5 101 011 001- AND 111- OR 110- 101 101 0 - 10
Input and Output
The input()
function allows you to take user input. By default, input is taken as a string.
Hands-on Quick Practice
Try solving the following problems:
Create two variables and print their sum.
Take two numbers from the user and print their product.
Perform binary AND, OR operations on two integers given by the user.
Write a program that asks for your age and prints how old you will be in 5 years.
Create a variable age and assign your age to it.
Print a greeting message using your name and age.
Perform and print the result of 25 % 4.
Take two numbers as input and print their sum.
Use binary operations to find the result of 12 & 7.