KEMBAR78
BSC Blockchain Lab Manual | PDF | String (Computer Science) | Computer Science
0% found this document useful (0 votes)
43 views26 pages

BSC Blockchain Lab Manual

This document is a lab manual for the Blockchain Lab course at Savitribai Phule Pune University for the academic year 2024-2025. It outlines a series of experiments aimed at demonstrating various blockchain concepts and Python operations, including ledger creation, hashing, and block structure. Each experiment includes an aim, code, expected output, and a section for learning and explanations.

Uploaded by

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

BSC Blockchain Lab Manual

This document is a lab manual for the Blockchain Lab course at Savitribai Phule Pune University for the academic year 2024-2025. It outlines a series of experiments aimed at demonstrating various blockchain concepts and Python operations, including ledger creation, hashing, and block structure. Each experiment includes an aim, code, expected output, and a section for learning and explanations.

Uploaded by

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

SAVITRIBAI PHULE PUNE

UNIVERSITY
Department Of Technology

SEMESTER – II
BLockchain LAB
Academic Year – 2024-2025
Course – Bachelor of Data Science
LAB MANUAL
SAVITRIBAI PHULE PUNE
UNIVERSITY
Department Of Technology

BSc. Data
Science
SEMESTER – II

Subject Name: BLockchain Lab


Name:
Roll No:
Submission Date:
Subject Teacher: Divesh Jadhwani

Internal Examiner External Examiner HOD Course


Coordinator Signature Signature
Signature Signature
INDEX PAGE

SR. LIST OF DATE SIGN


NO. EXPERIMENTS
Demonstrate python operation for
1. blockchain
26/2/2025

Demonstrate any simple ledger


2.
5/3/2025

Demonstrate a simple hospital ledger


3. using list of dictionaries.(without
hashing)
12/3/2025

Demonstrate an advanced hospital


4. ledger. (without hashing)
19/3/2025

Demonstrate hashlib library


5. operations
26/3/2025

Demonstrate a secured and optimized


6. performance ledger
2/4/2025

Demonstrate creation of a
7. block in block chain (without
hashing)
9/4/2025

Demonstrate block structure (without


8 hashing)
16/4/2025

Demonstrate block structure (with


9. hashing)
23/4/2025
Demonstrate creation of blockchain
10. (with hashing)
30/4/2025
EXPERIMENT NO – 1
Aim – Demonstrate python operation for blockchain
 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW

Python has several built-in data types. Understanding these is essential as they will help you store
and manipulate data for blockchain programs.

Common Data Types:

Integers (int) → Whole numbers like 5, -20, 100

Floating-point (float) → Decimal numbers like 3.14, 0.99, -5.5

Strings (str) → Text like "Bitcoin", "Ethereum"

Lists (list) → A collection of items like [1, 2, 3, 4]

Dictionaries (dict) → Key-value pairs like {"name": "Alice", "balance": 100}


EXPERIMENT NO – 2

Aim – Demonstrate any simple ledger

 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW
EXPERIMENT NO – 3

Aim – Demonstrate a simple hospital ledger using list of dictionaries.


(without hashing)

 CODE :

 Output:
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOw

The simple ledger will be a list that holds all these records.
Step 1: Define the Data Structure We will represent each patient’s visit as a dictionary, with the
following fields:

1. Patient Name
2. Treatment
3. Cost

Each visit will be stored as a dictionary in the ledger (which is a list).

We create an empty list hospital_ledger to store all the records. The function add_patient_visit takes
the patient's name, treatment, and cost as inputs and adds a dictionary representing the visit to the
hospital_ledger. We add a couple of visits for John Doe and Jane Smith.
EXPERIMENT NO – 4

Aim – Demonstrate an advanced hospital ledger. (without hashing)

 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOw

We’ll keep track of each visit separately, but this time, we’ll include more details like the date of
visit and allow the same patient to have multiple treatments.

Step 1: Updating the Data Structure We will update the ledger to store multiple visits for the same
patient by appending the visits in a nested list within each patient's dictionary. Each patient will
have a list of visits, where each visit contains:

1. Treatment
2. Cost
3. Date of Visit

he hospital_ledger_advanced is now a dictionary where the keys are patient names and the values
are lists of visits. The function add_patient_visit_advanced allows adding multiple visits for the same
patient by appending a visit to their list in the ledger. Each visit is represented as a dictionary with
details of the treatment, cost, and date. Exercise:

Add a few more visits for both John Doe and Jane Smith. Print the entire ledger to see how the data
is structured for each patient.
EXPERIMENT NO – 5

Aim – Demonstrate hashlib library operations


 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BEL

Hashing is a process where you take input data (like a text or number) and convert it into a fixed-
size string of characters.

The output of hashing is called a hash or digest.

Hashing is a one-way process, meaning once you get the hash, you cannot reverse it to get the
original data back.

Even a small change in the input data will produce a completely different hash.

A common use of hashing in blockchain and security is to ensure data integrity—that is, ensuring
that the data hasn't been tampered with.

 hashlib.sha256() creates a SHA-256 hash object.


 .encode() converts the string into bytes (which is required for hashing).
 .hexdigest() converts the hash object into a readable hexadecimal string.
EXPERIMENT NO – 6

Aim – Demonstrate a secured and optimized performance ledger


 CODE :

 Output:

 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW

One of the most important aspects of securing data is hashing. A hash is like a "digital fingerprint"
for any data.

Once we hash the data, it is nearly impossible to reverse the hash to get the original data. This
ensures that our ledger’s records can’t be tampered with.

We will use the SHA-256 hash function (a common cryptographic hash function) to secure our
records. By hashing the entire record (patient’s name, treatment, cost, and date), we can make sure
that no one can change the record without being detected.
EXPERIMENT NO – 7

Aim – Demonstrate creation of a block in block chain (without hashing)

 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW

A block in a blockchain is just a container that holds data.

Structure of a Block A block in a blockchain typically contains the following:

Data – The actual information stored in the block (e.g., transactions).

Timestamp – When the block was created. Previous Hash – The unique ID (hash) of the previous
block, linking them together.

Current Hash – A unique identifier for the block, generated using the data inside it.

Explanation:

index: Position of the block in the chain.

data: The actual information stored.

timestamp: When the block was created.

previous_block: The previous block’s reference (first block has None).


EXPERIMENT NO – 8

Aim – Demonstrate block structure (without hashing)

 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW
EXPERIMENT NO – 9
Aim – Demonstrate block structure (with hashing)
 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW
EXPERIMENT NO – 10
Aim – Demonstrate creation of blockchain (with hashing)
 CODE :

 Output :
 LEARNING:
NOTE – EXPLANATION SHOULD BE WRITTEN DOWN BELOW

You might also like