لغة برمجة بايثون Python تعتبر واحدة من أسهل لغات البرمجة للتعلم. بالأضافة الى ذلك ، يزداد الطلب عليه في مجال تطوير البرمجيات. يسمح لك بالقيام بمهام شاقة. في هذه المقالة ، نلقي نظرة على بعض الأكواد الجاهزه من Python يمكنك استخدامها اليوم.

الأكواد أدناه بلغة البايثون

الكود بلغة بايثون  Python 



def convert(seconds):    seconds = seconds % (24 * 3600)    hour = seconds // 3600    seconds %= 3600    minutes = seconds // 60    seconds %= 60     return "%d:%02d:%02d" % (hour, minutes, seconds) # Driver program n = 12345 print(convert(n))


الكود بلغة بايثون  Python 



import math # Assign values to x and n x = 4 n = 3 # Method 1 power = x ** n print("%d to the power %d is %d" % (x,n,power)) # Method 2 power = pow(x,n) print("%d to the power %d is %d" % (x,n,power)) # Method 3 power = math.pow(2,6.5) print("%d to the power %d is %5.2f" % (x,n,power))


الكود بلغة بايثون  Python 



# Assign a value number = 50 # Check the is more than 50 or not if (number >= 50):    print("You have passed") else:    print("You have not passed")


الكود بلغة بايثون  Python 



import os import sys from PIL import Image
if len(sys.argv) > 1: if os.path.exists(sys.argv[1]): im = Image.open(sys.argv[1]) target_name = sys.argv[1] + ".jpg" rgb_im = im.convert('RGB') rgb_im.save(target_name) print("Saved as " + target_name) else: print(sys.argv[1] + " not found") else: print("Usage: convert2jpg.py <file>")


الكود بلغة بايثون  Python 

import fnmatch import os
rootPath = '/' pattern = '*.mp3'
for root, dirs, files in os.walk(rootPath):    for filename in fnmatch.filter(files, pattern):        print( os.path.join(root, filename))


الكود بلغة بايثون  Python 

import string from random import * characters = string.ascii_letters + string.punctuation  + string.digits password =  "".join(choice(characters) for x in range(randint(8, 16))) print (password)



الكود بلغة بايثون  Python 

# Declare a fruit list fruits = ["Mango","Orange","Guava","Banana"] # Insert an item in the 2nd position fruits.insert(1, "Grape") # Displaying list after inserting print("The fruit list after insert:") print(fruits) # Remove an item fruits.remove("Guava") # Print the list after delete print("The fruit list after delete:") print(fruits)


الكود بلغة بايثون  Python 

# Define the string string = 'Python Bash Java PHP PHP PERL' # Define the search string search = 'P' # Store the count value count = string.count(search) # Print the formatted output print("%s appears %d times" % (search, count))