فا

User codes archives

Public users codes are in this section. You can use these codes for learning or as a basic base for your code.

Python Medical EHR System with GUI and Data Structures

import tkinter as tk
from tkinter import messagebox, ttk
import matplotlib.pyplot as plt
from matplo ...
See and Run

Convert English Numbers to Persian in Python


ENGLISH_NUMBER_TO_PERSIAN = {
    "0": "۰",
    "1": "۱",
    "2": "۲",
    "3": "۳",
    "4": "۴", ...
See and Run

Calculate Compound Interest (FV) with Python

# P = مبلغ واریز ماهانه (تومان)
# R = نرخ سود سالانه (به درصد، مثلاً ۳۰)
# n = تعداد سال (اینجا ۲۰)
 ...
See and Run

Understanding intval() in PHP: Converting Data Types to Integer

<?php
$a = 32;
echo intval($a) . "<br>";

$b = 3.2;
echo intval($b) . "<br>";

$c = "32.5";
echo int ...
See and Run

Generate Secure Random Passwords in Python

import secrets
import string

def generate_password(length=12, min_digits=2, min_special=2):
    ...
See and Run

Solve N-Queens Problem in PHP with Backtracking

<?php

function printBoard($board) {
    foreach ($board as $row) {
        echo implode(' ', $row)  ...
See and Run

Sort Dictionary in Python | Complete Guide

# برنامه ای برای مرتب سازی یک دیکشنری در پایتون

# تعریف یک دیکشنری نمونه
my_dict = {"c": 3, "a": ...
See and Run

How to Get Integer Part of a Number in Python

# برنامه ای برای محاسبه و نمایش جزء صحیح یک عدد

# تعریف یک عدد اعشاری
number = 12.34567

# روش اول: ...
See and Run

Round Numbers to 2 Decimal Places in Python (3 Ways)

# برنامه ای برای نمایش یک عدد تا دو رقم اعشار

# تعریف یک عدد
number = 12.34567

# روش اول: است ...
See and Run

Python Sum 1 to 100: How to Use sum() and range()

# برنامه ای برای محاسبه جمع اعداد از 1 تا 100

# استفاده از تابع sum و range برای محاسبه جمع
total_s ...
See and Run

Find All Character Positions in a String with Python

fruits = 'apple and banana'
char_to_find = 'a'
index = 0
positions = []

while index < len(fruits):
 ...
See and Run

Extract File Extension in Python Using rindex

#استخراج پسوند فایل با پیدا کردن موقعیت آخرین نقطه
filename = "example.file.name.txt"
#استفاده از مت ...
See and Run

Convert Text to List by Lines in Python

txt = """Welcome to backendbaz,
where you can play
and learn!"""
#استفاده از متد splitlines
x = txt. ...
See and Run

Python rfind() Method: Find Last Occurrence of Substring

#به دست آوردن ایندکس آخرین مکان پیدا شدن حرف e در متن
txt = "Hello, welcome to my world."
x = txt.rf ...
See and Run

Python String title() Method: Capitalize Words

#تبدیل حرف اول تمام کلمات متن به حرف بزرگ و باقی حروف به حرف کوچک
txt = "Welcome to my world"
x = tx ...
See and Run

Convert Decimal to Hexadecimal in Python

a =  hex(255) # 0xff
b =  hex(25) # 0x19
c =  hex(0) # 0x0
d =  hex(130) # 0x82
print(a, b, c, d) ...
See and Run

How to Add an Item to a Python Dictionary with update()

#متد update
car = {
  "brand": "Ford",
  "model": "Mustang",
   "year": 1964
}
car.update({"color":  ...
See and Run

Display City Temperatures & Find Hottest with PHP

<?php

$cities = array(
    "Sari" => 17,
    "Yazd" => 40,
    "Tabriz" => -5,
    "Ahvaz" => 27,
  ...
See and Run

Print Odd Numbers in Python (Handling Negatives)

def print_odd_numbers(n):
    if n < 0:
        # برای اعداد منفی، از n تا -1 به عقب می‌رویم
        ...
See and Run

Difference of Squares in Python | Math Challenge

n = 100
sum1 = 0
for i in range(1, n + 1):
    sum1 = sum1 + i ** 2
    
sum2 = 0
for i in range(1,  ...
See and Run

Python all() Function with Data Types

#متد all
#بررسی می کند که آیا تمام مقادیر، True هستند یا نه
mylist = [True, True, True]
print(all(my ...
See and Run

PHP Person Class Example: Set Name, Get Name

<?php
class Person{
    private $name;
    
    public function setName(string $newName){
        $t ...
See and Run

Convert Dictionary to List in Python

#مثال یک دیکشنری 
my_dict = {'a': 1, 'b': 2, 'c': 3}

# تبدیل کلیدها به لیست
keys_list = list(my_dic ...
See and Run

Reverse a String in Python Using Slicing

def reverse_string(input_string):
    reversed_string = input_string[::-1]
    return reversed_strin ...
See and Run