Essential Python Programming Concepts and Examples
Mutable vs Immutable Data Types
- Mutable: Value can be changed after creation. Examples: list, dict, set.
- Immutable: Value cannot be changed after creation. Examples: int, float, string, tuple.
- Mutable objects can be modified in place; immutable objects create a new object on modification.
Break vs Continue Statements
- break: Terminates the loop immediately and control moves to the statement after the loop.
- continue: Skips the current iteration and moves to the next iteration of the loop.
for i in range(Read More
Implementing Android Intents and Content Providers
MainActivity.java
package com.example.lab4;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
Button btnExplicit, btnImplicit, btnContacts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Read More
Essential C Algorithms and Data Structures Implementation
Linear Search Implementation
#include <stdio.h>
#include <time.h>
int linearSearch(int arr[], int n, int key) {
for(int i = 0; i < n; i++) {
if(arr[i] == key) return i;
}
return -1;
}
int main() {
int arr[10000], n, key, pos;
clock_t start, end;
printf("Enter number of elements: ");
scanf("%d", &n);
printf("Enter elements:\n");
for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
printf("Enter element to search: ");
scanf( Read More
Essential Principles of Database Management Systems
Data Models
A data model is a conceptual representation of data structures required for a database system. It defines how data is stored, organized, and manipulated.
Types of Data Models
- Hierarchical Model: Arranges records in a hierarchy like an organization chart. Each record is a node; the top-most is the root. A child node can have only one parent, preventing multiple parent relationships.
- Network Model: Similar to the hierarchical model, but a child node can have multiple parents. It supports many-
Essential Java Enterprise Development Concepts
1. Object Relational Mapping (ORM)
ORM is a technique used to map Java objects to database tables. It allows developers to interact with databases using objects instead of raw SQL queries. Example: Hibernate is a popular ORM framework.
Advantages of ORM
- Reduced SQL Coding: Uses an object-oriented approach.
- Improved Productivity: Faster development with less code.
- Database Independence: Code works across different databases with minimal configuration changes.
- Maintainability: Clean, manageable code.
2.
Read MorePIC Microcontroller C Programming Examples
Practical 1: LED Blinking Patterns
#include <xc.h>
#define _XTAL_FREQ 20000000
#pragma config FOSC = HS, WDTE = OFF, PWRTE = ON, LVP = OFF
void delay_ms(unsigned int time) {
while(time--) __delay_ms(1);
}
void main(void) {
ANSEL = 0x00; ANSELH = 0x00;
TRISB = 0x00; PORTB = 0x00;
while(1) {
PORTB = 0xFF; delay_ms(500);
PORTB = 0x00; delay_ms(500);
PORTB = 0xAA; delay_ms(500);
PORTB = 0x55; delay_ms(500);
}
}Practical 2: DC Motor Control
# Read More
