Python File I/O, Strings, Control Flow and Data Structures
Python File I/O, Strings, Control Flow and Data Structures
File Input Examples
infile.read(1)
'T'
>>>>
infile.read(5)
'he 3 '
>>>>
infile.readline()
'lines in this file end with the new line
character.\n'
>>>>
infile.read()
'\nThere is a blank line above this line.\n'
>>>>
infile.close()File Output Examples
outfile = open('test.txt', 'w')
>>>>
outfile.write('T')
1
>>>>
outfile.write('his is the first line.')
22
>>>> Read More
React useEffect Patterns for Reliable Side Effects
🧠 useEffect Cheat Sheet (Beginner → Confident)
1️⃣ What is useEffect? (Plain English)
useEffect lets you run side effects in a React component.
👉 Side effects = things that are not UI rendering.
- Fetching data
- Calling APIs
- Using
localStorage - Timers (
setTimeout,setInterval) - Event listeners
- Updating the document title
Rule of thumb:
If it touches the outside world, it belongs inuseEffect.
2️⃣ Basic Syntax (Memorize This)
useEffect(() => {
// side effect code
}, [dependencies]);
📌 Two parts:
Read MoreCorrected VHDL Source: SRAM, CAM, State Machine
Corrected VHDL Source and Formatting
The following document preserves the original content while correcting spelling, capitalization, and HTML structure. All VHDL text has been kept but formatted for readability.
SRAM Read/Write Process
34
process(CLK, RST) begin
if (RST = '0') then
DATA <= (others => '0');
elsif (rising_edge(CLK)) then
if (WE = '1') then
SRAM(to_integer(unsigned(ADDRESS))) <= unsigned(DATA);
else
s_data_read_reg < Read More
Cloud Infrastructure: Virtualization and Storage Models
Virtualization Levels and Hardware Implementation
4. List and briefly describe the levels of virtualization. Describe in detail how virtualization works at the hardware / OS level. Virtualization can be implemented at different levels, depending on what part of the system is abstracted. The lecture classifies virtualization levels as: application level, library/user-level API, operating system level, hardware abstraction (HAL) level, and instruction set architecture (ISA) level. Each level virtualizes
Read MoreLinux vs Windows and macOS: Key Differences
⚖️ Comparison of Linux with Other Operating Systems
Linux, along with Microsoft Windows and Apple macOS, forms the triad of major operating systems. For exam purposes, the comparison focuses on their fundamental differences in cost, source model, security, and primary use case.
Fundamental Distinctions (Source Model & Cost)
| Feature | Linux (e.g., Ubuntu, Fedora) | Microsoft Windows (Proprietary) | Apple macOS (Proprietary) |
|---|---|---|---|
| Source Model | Open source (source code is freely available, modifiable, and distributable) |
C Programming Examples: Logic and Data Structures
C Programming Examples: Logic and Data Structures
<h3>1. Comparing Student Marks</h3>
<p>This program compares the marks of two students.</p>
<pre><code>#include <stdio.h>int main() { int studentA, studentB; printf(“Enter marks of Student A: “); scanf(“%d”, &studentA); printf(“Enter marks of Student B: “); scanf(“%d”, &studentB); if (studentA > studentB) { printf(“Student A scored higher with %d marks.\n”, studentA); } else if (studentB
