Python Learning
5.92K subscribers
426 photos
1 video
59 files
106 links
Python Coding resources, Cheat Sheets & Quizzes! πŸ§‘β€πŸ’»

Free courses: @bigdataspecialist

@datascience_bds
@github_repositories_bds
@coding_interview_preparation
@tech_news_bds

DMCA: @disclosure_bds

Contact: @mldatascientist
Download Telegram
Learn Python the Hard Way
Online
version (by the original author - no worries, this isn't a pirate link!) of the "Learn Python the Hard Way." book. It emphasizes repetition and concept understanding.

Author: Zed Shaw
Language: English
Level: Beginner

πŸ”— Read Online

#Python #Python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @programming_books_bds for more
Python print() Function
How to Print in Python with Examples

In the last post, we completed our first program. It’s time to print a message in python.

The print() function in Python is used to print a specified message on the screen. The print command in Python prints strings or objects which are converted to a string while printing on a screen.

Syntax:

print(object(s))

How to Print a simple String in Python?
More often then not you require to Print strings in your coding construct.

Here is how to print statement in Python 3:
To print the Welcome to Big Data, use the Python print statement as follows:

1   print ("Welcome to Big Data")

Output:
Welcome to Big Data

πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
❀3πŸ‘3
Python Variables: How to Define/Declare String Variable Types

What is a Variable in
Python?
A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing.

Python Variable Types
Every value in Python has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc. Variables in Python can be declared by any name or even alphabets like a, aa, abc, etc.

How to Declare and use a Variable
Let see an example. We will define variable in Python and declare it as β€œa” and print it.

1 a=100 
2 print (a)


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
60 Python Projects with Source Code

60 Python Projects with Source code solved and explained for free

Python has been in the top 10 popular programming languages for a long time, as the community of Python programmers has grown a lot due to its easy syntax and library support. In this article, I will introduce you to 60 amazing Python projects with source code solved and explained for free.

Python Projects with Source Code
Python Projects For Beginners:
If you’re a newbie to Python where you’ve just learned lists, tuples, dictionaries, and some basic Python modules like the random module, here are some Python projects with source code for beginners for you


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
Python Variable Types: Local & Global

There are two types of variables in Python, Global variable and Local variable. When you want to use the same variable for rest of your program or module you declare it as a global variable, while if you want to use the variable in a specific function or method, you use a local variable while Python variable declaration.

Let’s understand this Python variable types with the difference between local and global variables in the below program.

Let us define variable in Python where the variable β€œf” is global in scope and is assigned value 101 which is printed in output
Variable f is again declared in function and assumes local scope. It is assigned value β€œI am learning Python.” which is printed out as an output. This Python declare variable is different from the global variable β€œf” defined earlier
Once the function call is over, the local variable f is destroyed. At line 12, when we again, print the value of β€œf” is it displays the value of global variable f=101


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
πŸ‘2
How to Check Python Version on Linux, Mac & Windows

Python scripts can identify the version of Python installed on the computer. It enables you to validate if multiple versions are installed in the system. The script developed to check the Python version remains the same for windows OS, Mac OS, and Linux distributions. You can create a script by importing either the platform module or sys module of python.

import sys
sys. version

πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
πŸ‘1
How to Run Python Scripts: Step by Step Guide

What is the Script in
Python?
A script in Python can be defined as a file that consists of Python code or a program. It ends with an extension as .py
An interpreter can execute a script in two distinct ways, as listed below: –

A script can be executed as a module or as a script itself.
A code that is written in an interactive Python command prompt session manner.

How to run Python code and scripts interactively?
Here are steps to do this:

Step 1) The programmer must open the command line in the interactive mode.

Step 2) In the next step, invoke the python interpreter in the command line by typing the following command: –

Command:

python

πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
Python Escape Character Sequences (Examples)

Escape characters or sequences are illegal characters for Python and never get printed as part of the output. When backslash is used in Python programming, it allows the program to escape the next characters.

Following would be the syntax for an escape sequence

\Escape character

Here, the escape character could be t, n, e, or backslash itself.

Types of Escape Sequence

Escape characters can be classified as non-printable characters when backslash precedes them. The print statements do not print escape characters.


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
What is Tuple Matching in Python?

Tuple Matching in Python is a method of grouping the tuples by matching the second element in the tuples. It is achieved by using a dictionary by checking the second element in each tuple in python programming. However, we can make new tuples by taking portions of existing tuples.
Tuple Syntax
Tup = ('Jan','feb','march')

To write an empty tuple, you need to write as two parentheses containing nothing-
tup1 = ();

For writing tuple for a single value, you need to include a comma, even though there is a single value. Also at the end you need to write semicolon as shown below.
Tup1 = (50,);

Tuple indices begin at 0, and they can be concatenated, sliced and so on.
Tuple Assignment

Python has tuple assignment feature which enables you to assign more than one variable at a time. In here, we have assigned tuple 1 with the persons information like name, surname, birth year, etc. and another tuple 2 with the values in it like number (1,2,3,….,7).
For Example,
(name, surname, birth year, favorite movie and year, profession, birthplace) = Robert


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
πŸ‘3
Comparing tuples

A comparison operator in Python can work with tuples.
The comparison starts with a first element of each tuple. If they do not compare to =,< or > then it proceed to the second element and so on.
It starts with comparing the first element from each of the tuples
Let’s study this with an example-

#case 1
a=(5,6)
b=(1,4)
if (a>b):print("a is bigger")
else: print("b is bigger")

#case 2
a=(5,6)
b=(5,4)
if (a>b):print("a is bigger")
else: print ("b is bigger")

#case 3
a=(5,6)
b=(6,4)
if (a>b):print("a is bigger")
else: print("b is bigger")

Case1
: Comparison starts with a first element of each tuple. In this case 5>1, so the output a is bigger

Case 2: Comparison starts with a first element of each tuple. In this case 5>5 which is inconclusive. So it proceeds to the next element. 6>4, so the output a is bigger

Case 3: Comparison starts with a first element of each tuple. In this case 5>6 which is false. So it goes into the else block and prints β€œb is bigger.”


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
πŸ‘4
Using tuples as keys in dictionaries
Since tuples are hashable, and list is not, we must use tuple as the key if we need to create a composite key to use in a dictionary.

Example: We would come across a composite key if we need to create a telephone directory that maps, first-name, last-name, pairs of telephone numbers, etc. Assuming that we have declared the variables as last and first number, we could write a dictionary assignment statement as shown below:

directory[last,first] = number

Inside the brackets, the expression is a tuple. We could use tuple assignment in a for loop to navigate this dictionary.

for last, first in directory:
print first, last, directory[last, first]

This loop navigates the keys in the directory, which are tuples. It assigns the elements of each tuple to last and first and then prints the name and corresponding telephone number.

Tuples and dictionary

Dictionary can return the list of tuples by calling items, where each tuple is a key value pair.

a = {'x':100, 'y':200}
b = list(a.items())
print(b)


πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
πŸ‘4❀2
Deleting Tuples

Tuples are immutable and cannot be deleted. You cannot delete or remove items from a tuple. But deleting tuple entirely is possible by using the keyword

del

Slicing of Tuple

To fetch specific sets of sub-elements from tuple or list, we use this unique function called slicing. Slicing is not only applicable to tuple but also for array and list.

x = ("a", "b","c", "d", "e")
print(x[2:4])


The output of this code will be (β€˜c’, β€˜d’).

πŸ”— Read Online

#Python #python_3
βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–βž–
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
Forwarded from Free programming books
Please open Telegram to view this post
VIEW IN TELEGRAM