چنل پایتون | جنگو | برنامه نویسی وب سایت | HTML & CSS & JS
442 subscribers
296 photos
142 videos
41 files
213 links
ارتباط با مدیر:

@Amir_1234_ka
Download Telegram
ایجاد پسورد تصادفی با زبان سی

Random password with C

// Project Name -> Random Password Generator
// Programmer -> Amir Khadem

#include <stdio.h>
#include <windows.h>
#include <stdlib.h> // for srand
#include <time.h> // for time

void bar(char* message , int counter)
{
for(int i = 0;i < counter;i++)
{
printf("%c" , message[i]);
Sleep(30); // 30 millisecond
}
}

void menu()
{
char fmsg[] = "Welcome to the password generator";
char smsg[] = "[1] >>> create a random password";
char tmsg[] = "[2] >>> create a random password list";

int fcount = sizeof(fmsg) / sizeof(fmsg[0]);
int scount = sizeof(smsg) / sizeof(smsg[0]);
int tcount = sizeof(tmsg) / sizeof(tmsg[0]);

bar(fmsg , fcount);
printf("\n\n");
bar(smsg , scount);
printf("\n\n");
bar(tmsg , tcount);
printf("\n\n");

}

void password(int password_length , int choice , int counter , FILE *file)
{
char list[] = "1234567890qwertyuiopasdfghjklzxcvbnm,.<>/?;:'|{}[]!@#$^&*()_+=/*\"";

if(choice == 1)
{
printf("\n");

printf("\t password -> ");

for(int i = 0; i < password_length; i++)
{
printf("%c" , list[rand() % (sizeof (list) - 1)]);
}
printf("\n");
}
else if(choice == 2)
{
for(int j = 0; j < counter; j++)
{
for(int i = 0; i < password_length; i++)
{
fprintf(file, "%c", list[rand() % (sizeof(list) - 1)]);
}
fprintf(file , "\n");
}
}
}

int main()
{
FILE *file = fopen("password.txt" , "w");

char fmsg[] = "Enter a number -> ";
char smsg[] = "Enter password length -> ";
char tmsg[] = "How many password you want -> ";

int password_length , counter , choice;
int fcount = sizeof(fmsg) / sizeof(fmsg[0]);
int scount = sizeof(smsg) / sizeof(smsg[0]);
int tcount = sizeof(tmsg) / sizeof(tmsg[0]);

menu();
bar(fmsg , fcount);
scanf("%d" , &choice);

if(choice == 1)
{
bar(smsg , scount);
scanf("%d" , &password_length);
}
else if (choice == 2)
{
bar(smsg , scount);
scanf("%d" , &password_length);
bar(tmsg , tcount);
scanf("%d" , &counter);
}

srand(time(NULL));

password(password_length , choice , counter , file);

fclose(file);

return 0;
}
👍4
برای شمارش در لیست ها از چه چیز استفاده میکنیم ؟
Anonymous Quiz
3%
add
3%
pop
79%
count
15%
index
خروجی کد زیر چیست؟
def summing(x, y):
return x + y summing (2, 8)
Anonymous Quiz
25%
None
16%
2, 8
53%
10
6%
16
برای نمایش در صفحه از چه چیز استفاده میکنیم ؟
Anonymous Quiz
9%
document.write()
24%
alert
29%
show
فوری فوری

کلاس ها و شئ گرایی در پایتون👇

تمرین ۱:
کلاسی بنویسید که سگی که اسم او لوسی هست و سن او ۳ هست را نشان دهد
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age

def say(self):
print("Name = %s" % self.name)
print("Age = %s" % self.age)

my_dog = Dog('loosi', 3)
my_dog.say()
👍4
ی آمار بگیریم؟؟

فروردین:❤️
اردیبهشت:🔥
خرداد: 🥰

تیر: 😁
مرداد:🤔
شهریور:🤯

مهر:🥲
آبان:🤩
آذر:🥱

دی:🥴
بهمن:😍
اسفند:🌚

ماه تولدتون رو با ری اکشن پای این پیام نشون بدید. ممنون🌱😉
6🔥5🌚4🤔3😍3🥰2😁2🤯2🤩2😢1🥴1
چالش اینه:
برنامه ای بنویسید که به کاربر اجازه دهد یاد داشت هایی را ایجاد کند و در زمانی که کاربر بخواهد به آن یاد آوری شود
کسانی که میخوان در این چالش باشند به آیدی زیر پیام دهید:
@Amir_123_ka
چاپ Hello world در زبان های مختلف
👏3
import pygame
import random

# تنظیمات اولیه
pygame.font.init()

# اندازه صفحه
SCREEN_WIDTH = 300
SCREEN_HEIGHT = 600
BLOCK_SIZE = 30
COLS = 10
ROWS = 20

# رنگ‌ها
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
CYAN = (0, 255, 255)
MAGENTA = (255, 0, 255)
YELLOW = (255, 255, 0)
ORANGE = (255, 165, 0)

SHAPES = [
[[1, 1, 1, 1]], # I
[[1, 1, 1], [0, 1, 0]], # T
[[1, 1], [1, 1]], # O
[[1, 1, 0], [0, 1, 1]], # S
[[0, 1, 1], [1, 1, 0]], # Z
[[1, 0, 0], [1, 1, 1]], # L
[[0, 0, 1], [1, 1, 1]], # J
]

SHAPES_COLORS = [CYAN, MAGENTA, YELLOW, GREEN, RED, BLUE, ORANGE]

# کلاس برای اشکال تتریس
class Piece(object):
def init(self, shape, color):
self.shape = shape
self.color = color
self.x = 3
self.y = 0

def rotate(self):
self.shape = [list(row) for row in zip(*self.shape[::-1])]

# کلاس برای صفحه بازی
class Tetris(object):
def init(self):
self.board = [[BLACK for _ in range(COLS)] for _ in range(ROWS)]
self.gameover = False
self.score = 0
self.current_piece = self.new_piece()
self.next_piece = self.new_piece()

def new_piece(self):
shape = random.choice(SHAPES)
color = SHAPES_COLORS[SHAPES.index(shape)]
return Piece(shape, color)

def valid_space(self, piece):
for y, row in enumerate(piece.shape):
for x, cell in enumerate(row):
if cell:
if x + piece.x < 0 or x + piece.x >= COLS or y + piece.y >= ROWS or self.board[y + piece.y][x + piece.x] != BLACK:
return False
return True

def place_piece(self):
for y, row in enumerate(self.current_piece.shape):
for x, cell in enumerate(row):
if cell:
self.board[y + self.current_piece.y][x + self.current_piece.x] = self.current_piece.color

def clear_lines(self):
lines_to_clear = []
for i, row in enumerate(self.board):
if BLACK not in row:
lines_to_clear.append(i)
if lines_to_clear:
self.score += len(lines_to_clear)
for i in lines_to_clear:
del self.board[i]
self.board.insert(0, [BLACK for _ in range(COLS)])

def draw_board(self, win):
for y, row in enumerate(self.board):
for x, color in enumerate(row):
pygame.draw.rect(win, color, (x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))
for y, row in enumerate(self.current_piece.shape):
for x, cell in enumerate(row):
if cell:
pygame.draw.rect(win, self.current_piece.color, ((self.current_piece.x + x) * BLOCK_SIZE, (self.current_piece.y + y) * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE))

def move(self, dx, dy):
self.current_piece.x += dx
self.current_piece.y += dy
if not self.valid_space(self.current_piece):
self.current_piece.x -= dx
self.current_piece.y -= dy

def drop(self):
self.current_piece.y += 1
if not self.valid_space(self.current_piece):
self.current_piece.y -= 1
self.place_piece()
self.clear_lines()
if self.current_piece.y == 0:
self.gameover = True
self.current_piece = self.next_piece
self.next_piece = self.new_piece()

def rotate(self):
self.current_piece.rotate()
if not self.valid_space(self.current_piece):
self.current_piece.rotate()
self.current_piece.rotate()
self.current_piece.rotate()

# تابع برای راه‌اندازی بازی
def draw_text_middle(text, size, color, surface):
font = pygame.font.Font(pygame.font.get_default_font(), size)
label = font.render(text, 1, color)
surface.blit(label, (SCREEN_WIDTH / 2 - (label.get_width() / 2), SCREEN_HEIGHT / 2 - (label.get_height() / 2)))