Skip to content

Instantly share code, notes, and snippets.

View chathudilzo's full-sized avatar
🏠
Working from home

Chathura Dilshan chathudilzo

🏠
Working from home
View GitHub Profile
@chathudilzo
chathudilzo / git-dev-master.markdown
Created January 11, 2024 13:16 — forked from withoutwax/git-dev-master.markdown
Guide on how to work with development branch and merge with master

Working with development branch and merge with master

Sometimes you want to experiment with a code which you have on your master branch but not want to save it to master branch. In this case, you can create another branch where you can experiment with ease - and if you are satisfied, you can merge the experiment to the master branch later.

Creating development branch

git branch development
git checkout development
git add .
git commit -m "Initial commit on development branch"
git push origin development
@chathudilzo
chathudilzo / immutability_dart_class.dart
Last active January 2, 2024 11:37
immutability_dart_class
void main() {
print('Hello world');
// Creating an instance of the Model class
var model1 = const Model('Chathura', 14, 'SL');
// Accessing properties of model1
print(model1.name);
print(model1.address);
@chathudilzo
chathudilzo / dictionaries.py
Created October 27, 2023 16:46
inventory management system that allows users to perform various operations on an inventory, including adding, updating, removing items, checking quantities, and calculating the total stock value.
def main():
inventory={}
value=100
print("INVENTORY MANAGEMENT SYSTEM!")
while value>0:
print(inventory)
def main():
daily_sales=[100,150,200,180,220,300,250]
#simple for loop for calculate total sales
total_sales=0
for sale in daily_sales:
@chathudilzo
chathudilzo / booleans.py
Created October 25, 2023 20:31
# Real-World Problem: Securing a Bank Vault
def main():
user_inputs=[]
alarm_activated=input("Is the alarm system activated? (True/False): ").lower()=='true'
user_inputs.append(alarm_activated)
camera_operational=input("Is security camera operational? (True/False): ").lower()=='true'
user_inputs.append(camera_operational)
@chathudilzo
chathudilzo / functions.py
Created October 25, 2023 18:46
# Real-World Problem: Finding the Closest Temperatures # In this scenario, we want to help a weather analyst who is analyzing historical temperature data # for a city. The analyst has collected temperature readings at different times of the day and # wants to determine the smallest temperature difference between any two readings to identify # wh…
# Real-World Problem: Finding the Closest Temperatures
# In this scenario, we want to help a weather analyst who is analyzing historical temperature data
# for a city. The analyst has collected temperature readings at different times of the day and
# wants to determine the smallest temperature difference between any two readings to identify
# when the temperature changed the least during the day.
def main():
temperature_data=[]
@chathudilzo
chathudilzo / arithmatic_quiz.py
Created October 24, 2023 10:34
# Arithmatic Quiz in Python This Python script presents an arithmetic quiz to the user. It generates random arithmetic problems, evaluates them, and checks the user's answers. ## Features - Generates random arithmetic problems involving addition, subtraction, multiplication, division, floor division, modulus, exponentiation, and negation. - Disp…
import random
def main():
print("Welcome to the arithmatic quiz")
score=0
num_problems=5
for _ in range(num_problems):