Python Strings and Functions Reference: Methods & Examples
Python String Cheat Sheet
===========================
Python String Cheat Sheet
===========================
Strings are
- Indexed
- Iterable
- Immutable
Indexing & Slicing
———————————–
s = "python"
s[0] -> 'p'
s[-1] -> 'n'
Slicing:
s[start:end] -> s[1:4] = 'yth'
s[:3] -> 'pyt'
s[3:] -> 'hon'
s[::2] -> 'pto'
s[::-1] -> reversed stringImportant String Methods
———————————–
Case
s.
Python Essentials: Functions, Loops, Data Structures & More
Python Essentials
1. Functions
Defining a Function:
pythondef function_name(parameters): # Code blockCalling a Function:
pythonfunction_name(arguments)Default Parameters:
pythondef greet(name="User"): print(f"Hello, {name}!") greet() # "Hello, User!" greet("Alice") # "Hello, Alice!"Return Statement:
pythondef add(a, b): return a + b result = add(3, 5) # result is 8Function Scope (Local vs Global):
- Local variables are accessible only within the function.
- Global variables are accessible
C Student Data Management: Code Analysis & Implementation
This document presents a C program designed for managing student information. It includes header files, source code, and a main function demonstrating the program’s functionality.
studentinfo.h
#ifndef STUDENTINFO_H
#define STUDENTINFO_H
#define MAX_SIZE 10
typedef struct student{
char name[30];
char student_Ids[50];
int student_grades[10];
int gradeavg;
}student;
void print_students (student[], int);
student return_student(student[], int, char []);
#endif