404
+ +Page not found
+ + +diff --git a/compile-pages.sh b/compile-pages.sh new file mode 100755 index 0000000..f6c3ddc --- /dev/null +++ b/compile-pages.sh @@ -0,0 +1,11 @@ +echo 'Cleaning documentation_utils directory' +rm -rf documentation_utils/* + +echo 'Copying the README over to the pages' +cat README.md >> documentation_utils/index.md + +echo 'Compiling pages from python to markdown content' +python3 python_to_markdown_compiler.py + +echo 'Building the documentation' +mkdocs build --clean diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..f669eed --- /dev/null +++ b/docs/404.html @@ -0,0 +1,414 @@ + + + +
+ + + + + + +Page not found
+ + +Created by Amr_Aly +Creation date : 02/07/2018 +It's a simple function to calculate your age +The error that will occur by the date 29/02/1980 or 84 or 88 or 92 or 96 or...etc +This error is almost one day you can neglect it +I think that it's very useful procedure if you use it in +a real project with datetimepicker and textbox +your birth date = y1, m1, d1 +current date = y2, m2, d2
+ def calculate_age(y1, m1, d1, y2, m2, d2):
+
+ if d2 < d1:
+ d2 = d2 + 30
+ m2 = m2 - 1
+ if m2 < m1:
+ m2 = m2 + 12
+ y2 = y2 - 1
+
+ years = int(y2 - y1)
+ months = int(m2 - m1)
+ days = int(d2 - d1)
+ your_age = str(years) + ' Years', str(months) + ' Months', str(days) + ' Days'
+
+ return your_age
+
+This date 29/2/1984 as an example its result must be (34 years, 4 months , 2 days) +But with this method the result will be(34 years, 4 months , 3 days) +you see now that you can neglect it , one day only is the difference +Don't forget that . It's a simple procedure
+ print calculate_age(1984,2,29,2018,7,2)
+
+
+ from __future__ import print_function
+
+Syntax +def function_name( parameters ): ==>parameters means passing argument to function +block of code +retrun or print
+ print ("Example 1")
+ def names(x):
+ print(x)
+ names("dima")
+ print ("----------------")
+
+
+ print ("Example 2")
+ def emplpyee_name():
+ name=["Sara","Ahmad","Dima","Raed","Wael"]
+ return name
+ print(emplpyee_name())
+ print ("----------------")
+
+ print ("Example 3")
+ def sum(x,y):
+ s = x + y
+ return s
+ print(sum(3,4))
+ print ("----------------")
+
+ print ("Example 4")
+ def sum(x,y=6):
+ s = x + y
+ return s
+ print(sum(3))
+ print ("----------------")
+
+
+ from __future__ import print_function
+
+Example about function and if .. elif statment
+ try:
+ raw_input # Python 2
+ except NameError:
+ raw_input = input # Python 3
+
+
+ def Game():
+ playerOne_points = 0
+ playerTwo_points = 0
+ while True:
+ print("Choose one of this choices: \n1- Rock \n2- Paper \n3- Scissors")
+ first_player = int(raw_input("Player one enter your choice: ").strip())
+ ch_list=[1,2,3]
+ while first_player not in ch_list:
+ print("incorrect choice , Try again ")
+ first_player = int(raw_input("Player one enter your choice: ").strip())
+ second_player = int(raw_input("Player two enter your choice: ").strip())
+ while second_player not in ch_list:
+ print("incorrect choice , Try again ")
+ second_player = int(raw_input("Player two enter your choice: ").strip())
+
+ if first_player == 1 and second_player == 3: # Rock breaks scissors
+ playerOne_points += 1
+ elif second_player == 1 and first_player == 3:
+ playerTwo_points += 1
+ elif first_player == 3 and second_player == 2: # Scissors cuts paper
+ playerOne_points += 1
+ elif second_player == 3 and first_player == 2:
+ playerTwo_points += 1
+ elif first_player == 2 and second_player == 1: # Paper covers rock
+ playerOne_points += 1
+ elif second_player == 2 and first_player == 1:
+ playerTwo_points += 1
+ if playerOne_points > playerTwo_points:
+ print("Player one won: " + str(playerOne_points)+ " VS "+ str(playerTwo_points))
+ else:
+ print("Player two won: " + str(playerTwo_points)+ " VS "+ str(playerOne_points))
+ answer = raw_input("Do you want to continue? Y/N ").strip().upper()
+ if answer == "N":
+ break
+
+ Game()
+
+
+ This file contains some examples for built-in functions in python +they are functions that do certain things +I will explain
+example 1 = .upper() +added by @basmalakamal
+ str1 = "hello world"
+ print str1.upper()
+
+this how we use it and it is used to return the string with capital letters
+example 2 = isupper() +added by @basmalakamal
+ str2 = "I love coding"
+ print str2.isupper()
+
+this function returns a boolean it is used to see if all letters in the string are capital I have only one capital letter here +so it returned False +lets try again here
+ str3 = "PYTHON IS AWESOME"
+ print str3.isupper() #prints True
+
+example 3 = lower() +added by @basmalakamal
+ str4 = "BASMALAH"
+ print str4.lower()
+
+it returns the string with small letters
+example 4 = islower() +added by @basmalakamal
+ str5 = "Python"
+ print str5.islower()
+
+this function returns a boolean it is used to see if all letters in the string are small I have one capital letter here +so it returned False +lets try again here
+ str6 = "python"
+ print str6.islower() #prints True
+
+example 5 = float() +added by @basmalakamal
+ print float('12\n')
+
+we can use this one to input an integer and it will return a float depends on what you have written +for example I wrote 12\n (\n means a space) so it returned 12.0
+example 6 = id() +added by @basmalakamal
+ print id(str6)
+
+it returns the identity of any object cause every object has an identity in python memory
+example 7 = len() +added by @basmalakamal
+example 8 = int() +added by @basmalakamal
+example 9 = str() +added by @basmalakamal
+example 10 = max() +added by @basmalakamal
+example 11 = sort() +added by @basmalakamal
+example 12 = replace() +added by @basmalakamal
+example 13 = append() +added by @basmalakamal
+example 14 = index() +added by @basmalakamal
+example 15 = split() +added by @basmalakamal
+example 16 = join() +added by @basmalakamal
+ +what is the output of this code?
+ gun = lambda x:x*x
+ data = 1
+ for i in range(1,3):
+ data+=gun(i)
+ print(gun(data))
+
+
+ from math import *
+
+round
+ print round(3.99999)
+ print round(66.265626596595, 3)
+
+abs
+ print abs(-22)
+
+max
+ print max(10,8,6,33,120)
+
+min
+ print min(10,8,6,33,120)
+
+pow
+ print pow(6.3 , 1.5)
+
+sqrt
+ print sqrt(4)
+
+ceil
+ print ceil(7.666)
+
+copysign
+ print copysign(1,-1)
+
+
+ this file print out the fibonacci of the function input
+importing numpy for execute math with lists
+ import numpy as np
+
+define the function that takes one input
+ def fibonacci_cube(num):
+ #define a list that contains 0 and 1 , because the fibonacci always starts with 0 and 1
+ lis = [0,1]
+ #this for loop takes the range of the parameter and 2
+ for i in range(2,num):
+ #appending the sum of the previuos two numbers to the list
+ lis.append(lis[i-2] + lis[i-1])
+ #finally returning the cube of the fibonacci content
+ return np.array(lis)**3
+
+calling the function with 8 as an example
+ print fibonacci_cube(8)
+
+
+ added by @Azharoo +Python 3
+ def revirse_string(word):
+ s=""
+ word= word.split()
+ for e in word:
+ s+= e[::-1] + " "
+ print s
+
+
+ word="Welcome to pythonCodes on GitHub"
+
+ revirse_string(word)
+
+
+ strip() returns a copy of the string +in which all chars have been stripped +from the beginning and the end of the string
+lstrip() removes leading characters (Left-strip) +rstrip() removes trailing characters (Right-strip)
+Syntax +str.strip([chars]);
+Example 1 +print Python a high level
+ str = "Python a high level language";
+ print str.strip( 'language' )
+
+Examlpe 2
+ str = "Python a high level language , Python")
+
+print a high level language ,
+ print str.strip("Python")
+
+print a high level language , Python
+ print str.lstrip("Python")
+
+print Python a high level language ,
+ print str.rstrip("Python")
+
+
+ added by @Dima
+ EmployeeName = {"Dima":"2000",
+ "Marwa":"4000",
+ "Sarah":"2500"}
+
+ print(EmployeeName)
+
+ print len(EmployeeName)
+
+
+ EmployeeName["Dima"] = 5000
+ print(EmployeeName)
+
+
+ added by @Azharoo +Python 3
+The pop() method removes and returns the element at the given index (passed as an argument) from the list. +If no parameter is passed, the default index -1 is passed as an argument which returns the last element.
+Example 1: Print Element Present at the Given Index from the List
+programming language list
+ language = ['Python', 'Php', 'C++', 'Oracle', 'Ruby']
+
+Return value from pop() When 3 is passed
+ print('When 3 is passed:')
+ return_value = language.pop(3)
+ print('Return Value: ', return_value)
+
+Updated List
+ print('Updated List: ', language)
+
+Example 2: pop() when index is not passed and for negative index
+programming language list
+ language = ['Python', 'Php', 'C++', 'Oracle', 'Ruby']
+
+When index is not passed
+ print('\nWhen index is not passed:')
+ print('Return Value: ', language.pop())
+ print('Updated List: ', language)
+
+When -1 is passed Pops Last Element
+ print('\nWhen -1 is passed:')
+ print('Return Value: ', language.pop(-1))
+ print('Updated List: ', language)
+
+When -3 is passed Pops Third Last Element
+ print('\nWhen -3 is passed:')
+ print('Return Value: ', language.pop(-3))
+ print('Updated List: ', language)
+
+
+ added by @Azharoo +Python 3
+The remove() method searches for the given element in the list and removes the first matching element. +If the element(argument) passed to the remove() method doesn't exist, valueError exception is thrown.
+Example 1: Remove Element From The List +animal list
+ animal = ['cat', 'dog', 'rabbit', 'cow']
+
+'rabbit' element is removed
+ animal.remove('rabbit')
+
+Updated Animal List
+ print('Updated animal list: ', animal)
+
+Example 2: remove() Method on a List having Duplicate Elements +If a list contains duplicate elements, the remove() method removes only the first instance
+animal list
+ animal = ['cat', 'dog', 'dog', 'cow', 'dog']
+
+'dog' element is removed
+ animal.remove('dog')
+
+Updated Animal List
+ print('Updated animal list: ', animal)
+
+Example 3: Trying to Delete Element That Doesn't Exist +When you run the program, you will get the following error: +ValueError: list.remove(x): x not in list
+animal list
+ animal = ['cat', 'dog', 'rabbit', 'cow']
+
+Deleting 'fish' element
+ animal.remove('fish')
+
+Updated Animal List
+ print('Updated animal list: ', animal)
+
+
+ added by @Azharoo +Python 3
+The reverse() يعكس عناصر قائمة محددة. +The reverse() لا تأخذ أي عوامل. +The reverse() لا يعيد أي قيمة. يقوم فقط عكس العناصر وتحديث القائمة.
+مثال 1 : Reverse a List
+Operating System List
+ os = ['Windows', 'macOS', 'Linux']
+ print('Original List:', os)
+
+List Reverse
+ os.reverse()
+
+updated list
+ print('Updated List:', os)
+
+Example 2: Reverse a List Using Slicing Operator
+Operating System List
+ os = ['Windows', 'macOS', 'Linux']
+ print('Original List:', os)
+
+Reversing a list +Syntax: reversed_list = os[start:stop:step]
+ reversed_list = os[::-1]
+
+updated list
+ print('Updated List:', reversed_list)
+
+Example 3: Accessing Individual Elements in Reversed Order
+Operating System List
+ os = ['Windows', 'macOS', 'Linux']
+
+طباعة القائمة بشكل معكوس
+ for o in reversed(os):
+ print(o)
+
+مثال 4 : (شرح الاستاذ الفاضل ريمون )
+ def my_f(list):
+ list1 = list.reverse()
+ return list1
+
+ list =[10,20,40]
+
+ print(my_f(list)) ## الناتج هنا None
+
+
+
+ def my_f(list):
+ list1 = list.reverse()
+ return list
+
+ list =[10,20,40]
+
+ print(my_f(list))## [40, 20, 10]
+
+لماذا الناتجين مختلفين
+ببساطة
+فى المرة الاولى
+reverse() +هى قامت بالتعديل على القائمة لكن لاتقوم باخراج القائمة الجديدة
+لكن تم التعديل بالفعل على القائمة واذا تمت طباعة القائمة نجد ان
+قيم العناصر قد انقلبت بالعكس
+وهو ماحدث فى الكود الحالى عندما قمنا بارجاع قيمة القائمة
+وتمت طباعة القيمة بالفعل
+بينما فى المرة الاولى … ما طلبنا اخراجه هو العملية نفسها … وليست القيمة
+ +added by @Azharoo +Python 3
+The reverse() method reverses the elements of a given list. +The reverse() function doesn't take any argument. +The reverse() function doesn't return any value. It only reverses the elements and updates the list.
+os = ['Windows', 'macOS', 'Linux'] +print('Original List:', os)
+os.reverse()
+print('Updated List:', os)
+os = ['Windows', 'macOS', 'Linux'] +print('Original List:', os)
+reversed_list = os[::-1]
+print('Updated List:', reversed_list)
+os = ['Windows', 'macOS', 'Linux']
+for o in reversed(os): + print(o)
+def my_f(list): + list1 = list.reverse() + return list1
+list =[10,20,40]
+print(my_f(list)) ## The result is None
+def my_f(list): + list1 = list.reverse() + return list
+list =[10,20,40]
+print(my_f(list))## [40, 20, 10]
+ +added by @Dima +Empty
+ x = {}
+ print(x)
+
+print ('Dima', 'Marwa', 'Sarah')
+ EmployeeName = {"Dima", "Marwa", "Sarah"}
+ print(EmployeeName)
+
+print length = 3
+ print len(EmployeeName)
+
+print Sarah +print EmployeeName[2] this will give an error because the set has unindex
+remove marwa
+ EmployeeName.remove("Marwa")
+ print EmployeeName
+
+
+ added by @Azharoo +Python 3 +Python slicing is a computationally fast way to methodically access parts of your data.
+Create a list of science subjects and another list of integers from 1-10
+ subjects = ['IT-Science','physics','biology','mathematics']
+ x=list(range(1,11))
+
+slicing the entire list.
+ subjects[:]
+ ['IT-Science', 'physics', 'biology', 'mathematics']
+ x[:]
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+
+Slicing from index 0 up to the last index with a step size of 2.
+ subjects[::2]
+ ['IT-Science', 'biology']
+ x[::2]
+ [1, 3, 5, 7, 9]
+
+Slicing from index 9 down to the last index with a negative step size of 2.
+ x[9:0:-2]
+ [10, 8, 6, 4, 2]
+ """Slicing from last index from the right of the list
+ down to the last index of the left of the list with a
+ negative step size of 3."""
+ x[::-3]
+ [10, 7, 4, 1]
+
+
+ added by @Dima +Empty
+ x = ()
+ print(x)
+
+print ('Dima', 'Marwa', 'Sarah')
+ EmployeeName = ("Dima", "Marwa", "Sarah")
+ print(EmployeeName)
+
+print length = 3
+ print len(EmployeeName)
+
+print Sarah
+ print EmployeeName[2]
+
+
+ Added by @ammarasmro
+Comprehensions are very convenient one-liners that allow a user to from a +whole list or a dictionary easily
+One of the biggest benefits for comprehensions is that they are faster than +a for-loop. As they allocate the necessary memory instead of appending an +element with each cycle and reallocate more resources in case it needs them
+ sample_list = [x for x in range(5)]
+ print(sample_list)
+
+++++++[0,1,2,3,4]
+
Or to perform a task while iterating through items
+ original_list = ['1', '2', '3'] # string representations of numbers
+ new_integer_list = [int(x) for x in original_list]
+
+A similar concept can be applied to the dictionaries
+ sample_dictionary = {x: str(x) + '!' for x in range(3) }
+ print(sample_dictionary)
+
+++++++{0: '0!', 1: '1!', 2: '2!'}
+
Conditional statements can be used to preprocess data before including them +in a list
+ list_of_even_numbers = [x for x in range(20) if x % 2 == 0 ]
+ print(list_of_even_numbers)
+
+++ +++++[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
+
string="ali ahmed salm"
+ print (string.find("sa"))
+ print (string.find(""))
+ print (string.find (" "))
+ print (string.find("ah",3,5))
+ print (string.find("ah",3,6))
+ def get_s(a, b):
+ return a[:b]
+ print(get_s("mySchool",10))
+
+
+ This file contains some examples for Python Lists +How to create lists +how to print lists
+example 1 +added by @engshorouq +empty list
+ my_list=[]
+
+list of integers
+ my_list=[1,2,3,4,5]
+
+list with mixed datatype
+ my_list=[2,"python",2.2]
+
+example 2 +added by @engshorouq +to print specific index
+ my_list=['p','y','t','h','o','n']
+ print("first index in the list in positive index : ",my_list[0])
+ print("first index in the list in negative index : ",my_list[-5])
+
+to print a range of items in the lists
+ print("from beginning element to end : ",my_list[:])
+ print("from the second element to fifth element : ",my_list[1:4])
+ print("from beginning to the second : ",my_list[:-5])
+ print("from second to end element : ",my_list[1:])
+
+
+ This file contains some examples for Python Lists +How to create lists +how to print lists
+example 1 +added by @engshorouq +empty list
+ my_list=[]
+
+example 2 +added by anonymous +define a list with numbers from 1-5
+ my_list=[1,2,3,4,5]
+
+example 3 +added by anonymous +list with mixed datatype
+ my_list=[2,"python",2.2]
+
+example 4 +added by @engshorouq +print specific index
+ my_list=['p','y','t','h','o','n']
+ print("first index in the list in positive index : ",my_list[0])
+ print("first index in the list in negative index : ",my_list[-5])
+
+to print a range of items in the lists
+ print("from beginning element to end : ",my_list[:])
+ print("from the second element to fifth element : ",my_list[1:4])
+ print("from beginning to the second : ",my_list[:-5])
+ print("from second to end element : ",my_list[1:])
+
+
+ how to add element to lists +how to modify elements in the lists
+example1 +added by @engshorouq +create empty list
+ my_list=[]
+
+add element to empty string in two ways the first way(append)
+ my_list.append("Learn")
+ my_list.append(["Pythn","Language"])
+
+print list to show the output
+ print("list after adding iteam using append : \n",my_list)
+
+add element to my list by second way : using + operator
+ my_list=my_list+["version"]
+ my_list=my_list+[3]
+ my_list=my_list+["interting","language"]
+
+print list to show output
+ print("\nlist after adding iteam using append : \n",my_list)
+
+mistake in writing word inside list +modify 1st iteam
+ my_list[0]="Learning"
+
+modify 2nd item the 1st item inside it
+ my_list[1][0]="Python"
+
+modify 3rd to 5th item
+ my_list[2:5]=["version 3","intersting","language"]
+
+print list to show output
+ print("\nlist after modification : \n",my_list)
+
+
+ الدالة pop() تقوم بحذف اخر عنصر بالقائمة +نستطيع ان نحدد العنصر المراد حذفه وذلك بتحديد اندكس العنصر بداخل القوسين
+المثال الاول
+ li = [2,3,4,5]
+ li.pop()
+ print li #[يطبع [2,3,4
+
+المثال الثاني
+ li = [2,3,4,5]
+ li.pop(2)
+ print li #[يطبع [2,3,5
+
+الدالة pop لها قيمة ارجاع وهي العنصر المحذوف
+ li = [2,3,4,5]
+ print li.pop() # يطبع 5
+
+
+ from __future__ import print_function
+
+This file contain examples for os module +What is os module? +is a module using for list files in folder, we can get name of current working directory +rename files , write on files
+ import os
+
+ def rename_files():
+ # (1) get file names from a folder
+ file_list = os.listdir(r"C:\Users\user\Desktop\python\pythonCodes\Modules\images")
+ # r (row path) mean take the string as it's and don't interpreter
+ saved_path = os.getcwd()
+ print(saved_path)
+ saved_path = os.chdir(r"C:\Users\user\Desktop\python\pythonCodes\Modules\images")
+ for file_name in file_list:
+ os.rename(file_name , file_name.translate(None , "0123456789"))
+ print(saved_path)
+
+ rename_files()
+
+
+ from __future__ import print_function
+
+declare a class
+Synatx
+ #class ClassName:
+ #block of code
+
+Example 1 +init passing initial values to your object
+ class Car:
+
+ 'Print Car Name And Price'
+
+ def __init__(self,CarName,Price):
+ self.CarName = CarName
+ self.Price = Price
+
+ NewCar = Car("I8", 200000)
+
+ print("Car Name " + NewCar.CarName + " Car Price " + str(NewCar.Price))
+
+
+ print("Car.__doc__:", Car.__doc__)
+
+
+ from __future__ import print_function
+ class Person:
+
+ def __init__(self, first, last):
+ self.firstname = first
+ self.lastname = last
+
+ def Name(self):
+ return self.firstname + " " + self.lastname
+
+ class Employee(Person):
+
+ def __init__(self, first, last, staffnum):
+ Person.__init__(self,first, last)
+ self.staffnumber = staffnum
+
+ def GetEmployee(self):
+ return self.Name() + ", " + self.staffnumber
+
+ x = Person("Marge", "Simpson")
+ y = Employee("Homer", "Simpson", "1007")
+
+ print(x.Name())
+ print(y.GetEmployee())
+
+
+ added by Yassine Messaoudi AKA = TaKeO90 +This class is about to print kids info +Also use inheritance example
+ class Kid_info:
+
+
+
+ def __init__(self, first_name, last_name, age,school_level ) :
+ self.first_name = first_name
+ self.last_name = last_name
+ self.age = age
+ self.school_level = school_level
+
+Example
+ kid = Kid_info("Ahmed", "issa","10","primary school")
+
+
+ print (kid.first_name)
+ print (kid.last_name)
+ print (kid.age)
+ print (kid.school_level)
+
+inheritance example
+ class Parent(Kid_info) :
+
+
+
+ def __init__(self, first_name, last_name , age, work, number_of_kids):
+ self.first_name = first_name
+ self.last_name = last_name
+ self.age = age
+ self.work = work
+ self.number_of_kids = number_of_kids
+
+
+ Father = Parent("ahmed", "jalal", "35", "engenieer" , "2")
+
+ print (Father.work)
+
+
+ print Hello
+ print("Hello")
+
+ x, y = 1, 2
+
+print 1
+ print(x)
+
+print 2
+ print(y)
+
+print 3
+ print (x) + (y)
+
+print 1,2
+ print (x) , (y)
+
+print (1,2)
+ print (x,y)
+
+print [0] [0, 1]==> because it return range frim 0 to x-1
+ print range(x) ,range(y)
+
+
+ c="dima"
+ d="Hi"
+
+print dimaHi
+ print (c) + (d)
+
+print dima Hi
+ print (c)+(" ")+(d)
+
+print dima +Hi
+ print (c)+("\n")+(d)
+
+print DIMA hi
+ print (c).upper() , (d).lower()
+
+print 1 dima
+ print str(x) +(" ")+ (c)
+
+
+ string="ali ahmed salm"
+ print (string.find("sa"))
+ print (string.find(""))
+ print (string.find (" "))
+ print (string.find("ah",3,5))
+ print (string.find("ah",3,6))
+ def get_s(a, b):
+ return a[:b]
+ print(get_s("mySchool",10))
+
+
+ from __future__ import print_function
+
+هذا الملف يحتوي على بعض الامثله عن السلاسل النصيه للغة البايثون +ماهي السلاسل النصية في البايثون ؟ +السلاسل النصيه هي النوع الاكثر شعبية في لغة البايثون +نستطيع ان ننشئها بسهوله بواسطة علامات الاقتباس +لغة البايثون تتعامل مع علامات الاقتباس الفردية والزوجية على حد سواء +يمكن إنشاء السلاسل النصية بسهوله كإسناد قيمة إلى متغير +مصدر التعريف https://www.tutorialspoint.com/python/python_strings.htm
+مثال 1 +تمت مشاركتة بواسطة @remon +يقوم هذا المثال بطباعة السلسلة النصيه Hello World
+ str1 ="Hello World"
+ print(str1) # --> Hello World
+
+مثال 2 +تمت مشاركتة بواسطة @remon +يقوم هذا المثال بتوضيح تعامل الارقام كسلاسل نصية بداخل علامتي الاقتباس
+ str2 ='Hello World 2'
+ print(str2) # --> Hello World 2
+
+مثال 3 +تمت مشاركتة بواسطة @remon +مثال آخر عن طريقة تخزين الارقام كسلاسل نصية
+ str3 ="2018"
+ print(str3) # --> 2018
+
+مثال 4 +تمت مشاركتة بواسطة @tony.dx.3379aems5 +يوضح هذا المثال طريقة .....
+ str4 = "Hello 2 My friends 3"
+ num1 = int(str4[str4.find("2")])
+ num2 = int(str4[-1])
+ result = num1 + num2
+ print(result)
+
+مثال 5 +تمت مشاركتة بواسطة @Takeo. yassine messaoudi +يوضح هذا المثال طريقة إستخدام الدالة +replace(old,new) +لإستبدال الحروف في السلسلة النصية
+ str1 = "1 million arab coders "
+ a = str1.replace("m" , "M")
+ print (a) # --> 1 Million arab coders
+
+مثال 6 +تمت مشاركتة بواسطة @ammore5 +يوضح هذا المثال طريقة جمع سلسلتين نصيتين وطباعتهما
+ str1 = "hi "
+ str2 = "there !"
+ print (str1 + str2) # --> hi there !
+
+
+ from __future__ import print_function
+
+This file contains some examples for Python Strings +What is Strings in python ? +Strings are amongst the most popular types in Python. +We can create them simply by enclosing characters in quotes. +Python treats single quotes the same as double quotes. +Creating strings is as simple as assigning a value to a variable. +source of Definition https://www.tutorialspoint.com/python/python_strings.htm
+example 1 +added by @remon
+ str1 ="Hello World"
+ print(str1)
+
+example 2 +added by @remon
+ str2 ='Hello World 2'
+ print(str2)
+
+example 3 +added by @remon
+ str3 ="2018"
+ print(str3)
+
+example 4 +added by @tony.dx.3379aems5
+ str4 = "Hello 2 My friends 3"
+ num1 = int(str4[str4.find("2")])
+ num2 = int(str4[-1])
+ result = num1 + num2
+ print(result)
+
+example 5
+added by @Takeo. yassine messaoudi
+ str1 = "1 million arab coders "
+ a = str1.replace("m" , "M")
+ print (a)
+
+example 6 +added by @ammore5 +This example demonstrates how to concatenate two strings
+ str1 = "hi "
+ str2 = "there !"
+ print (str1 + str2)
+
+
+ from __future__ import print_function
+
+Imane OUBALID: Une jeune marocaine, titulaire d'un master en Réseaux et Systèmes Informatique. +Elle dispose d'un esprit d'analyse, de synthèse, d'une capacité d'adaptation aux nouvelles situations, +et elle est passionnée par la programmation et les nouvelles technologies.
+Booleen est un type de donnees qui ne peut prendre que deux valeurs logique: vrai (True) ou faux (False) +Il utilise d'autre expression tell que: et(and) non(not) ou(or) +A note il faut respecter l'ecriture des mots clea = 6
+voila un exemple simple d'expressions booleennes
+ A = 6
+ print((A == 7)) #renvoie la valeur logique False
+ print((A == 6)) #True
+
+l'utilisation de l'operateur non(not) renvoie l'oppose de la valeur
+ print('************ Operateur: not *************')
+ B = True
+ C = False
+ print((not B)) # resultat sera l'oppose de la valeur logique True = False(faux)
+ print((not not B))#True
+ print((not C))#True
+
+l'operateur and(et) renvoie Vrai si tous les valeurs sont vraies
+ print('************ Operateur: And *************')
+ print((True and True)) #True
+ print((True and False)) #False
+ print((False and True)) #False
+ print((False and False)) #False
+
+ D = 8
+ E = 9
+ print((D == 8 and D==9))#False
+ print((E == 9 and D==8))#True
+ print((not D and E==9))#False
+
+l'operateur or(ou) renvoie Vrai si ou moins une valeur est vraie
+ print('************ Operateur: or *************')
+ print((True or True)) #True
+ print((True or False)) #True
+ print((False or True)) #True
+ print((False or False)) #False
+
+ F=3
+ G=5
+ print((F==3 or F==0))#True
+ print((F==0 or G==0))#False
+ print((not F==0 or G==0))#True
+
+
+ from __future__ import print_function
+
+this is a logic table for (and, or) +before run this example you must *install library truths +in cmd run command pip install truths
+ from truths import Truths
+
+ try:
+ raw_input # Python 2
+ except NameError:
+ raw_input = input # Python 3
+
+ print("-------------------------------------------------------")
+ print("""Example Prerequisite : please insatll truths library
+ *Open CMD rum command pip install truths *""")
+ print("-------------------------------------------------------")
+
+ r = raw_input(" Are you install truths???? :) Y:Yes , N:NO :) ").strip().upper()
+
+ def emp(r):
+ if r=="Y":
+ print(Truths(['a', 'b', 'x']))
+ print(Truths(['a', 'b', 'cat', 'has_address'], ['(a and b)', 'a and b or cat', 'a and (b or cat) or has_address']))
+ print(Truths(['a', 'b', 'x', 'd'], ['(a and b)', 'a and b or x', 'a and (b or x) or d'], ints=False))
+ else:
+ print("------------------------")
+ print("------------------------")
+ print("Please to Install truths")
+ print("------------------------")
+ print("------------------------")
+ print("------------------------")
+ raw_input("")
+
+
+
+
+ print(emp(r))
+
+
+ from __future__ import print_function
+
+example1 +by @tony.dx.3379aems5
+ if True and False:
+ print ("False") #will not print
+ if True and True:
+ print ("True") #will print true
+ if False and False:
+ print ("False") #will not print
+
+
+ from turtle import *
+ goto(300, 0)
+ goto(300, 400)
+ goto(50, 400)
+ goto(0, 300)
+ goto(0, 0)
+ penup()
+ goto(50, 400)
+ pendown()
+ goto(100, 300)
+ goto(100, 0)
+ penup()
+ goto(0, 300)
+ pendown()
+ goto(100, 300)
+ goto(300, 300)
+ screensize(2000, 2000)
+
+
+ added by @Azharoo +Python 3
+Example - 1
+Draw one circle
+ import turtle
+
+ my_turtle = turtle.Turtle()
+ my_turtle.pencolor("red")
+
+ def circle(length,angle):
+ my_turtle.forward(length)
+ my_turtle.left(angle)
+
+ for i in range(46):
+ circle(10,8)
+
+
+ # Example - 2
+ #Draw Circle of Squares
+
+ import turtle
+
+ my_turtle = turtle.Turtle()
+ my_turtle.speed(0)
+ my_turtle.pencolor("blue")
+
+ def square(length,angle):
+ for i in range(4):
+ my_turtle.forward(length)
+ my_turtle.right(angle)
+
+ for i in range(100):
+ square(100,90)
+ my_turtle.right(11)
+
+Example - 3
+ #Draw beautiful_circles
+
+ import turtle
+ t = turtle.Turtle()
+ window = turtle.Screen()
+ window.bgcolor("black")
+ colors=["red","yellow","purple"]
+
+ for x in range(10,50):
+ t.circle(x)
+ t.color(colors[x%3])
+ t.left(90)
+
+ t.screen.exitonclick()
+ t.screen.mainloop()
+
+
+ https://github.com/asweigart/simple-turtle-tutorial-for-python/blob/master/simple_turtle_tutorial.md
+ from turtle import *
+ for i in range(500):# this "for" loop will repeat these functions 500 times
+ speed(50)
+ forward(i)
+ left(91)
+
+
+ added by @Azharoo +Python 3 +draw a simple rectangle
+Example - 1
+ import turtle
+ t = turtle.Turtle()
+ window = turtle.Screen()
+ window.bgcolor("black")
+ t.hideturtle()
+ t.color("red")
+
+ def slanted_rectangle(length,width):
+ for steps in range(2):
+ t.fd(width)
+ t.left(90)
+ t.fd(length)
+ t.left(90)
+
+ slanted_rectangle(length=200,width=100)
+
+Example - 2 +draw a slanted rectangle
+ import turtle
+ t = turtle.Turtle()
+ window = turtle.Screen()
+ window.bgcolor("black")
+
+
+ t.hideturtle()
+ t.color("red")
+
+ def slanted_rectangle(length,width,angle):
+ t.setheading(angle)
+ for steps in range(2):
+ t.fd(width)
+ t.left(90)
+ t.fd(length)
+ t.left(90)
+
+ slanted_rectangle(length=200,angle=45,width=100)
+
+
+ added by @Azharoo +Python 3 +draw a simple square
+Example - 1
+ import turtle
+ t = turtle.Turtle()
+ window = turtle.Screen()
+ window.bgcolor("black")
+ t.color("blue")
+ t.shape("turtle")
+ for i in range(4):
+ t.fd(100)
+ t.left(90)
+
+Example - 2
+ import turtle
+ t= turtle.Turtle()
+ t.screen.bgcolor("black")
+ t.color("red")
+ t.hideturtle() # Hide the turtle during the draw
+
+ def square(length):
+ for steps in range(4):
+ t.fd(length)
+ t.left(90)
+
+ square(100)
+
+
+ added by @Azharoo +Python 3
+Example - 1
+Draw triangle
+ import turtle
+ t = turtle.Turtle()
+ window = turtle.Screen()
+ window.bgcolor("black")
+
+ t.color("red")
+ t.hideturtle() # hide the turtle
+
+ def triangle(length,angle=120):
+ for steps in range(3):
+ t.fd(length)
+ t.left(angle)
+
+ triangle(200)
+
+
+ أضيفت من قبل @Modydj +Python 2.7 +2 in 1 (Twilio + Profanity Editor)
+آلية العمل:
+1- سأقوم بإنشاء دالة def تحت اسم see_me_that_in_phone
+2- سأجعله يعود للدالتين functions (check_profainty, read_text)
+3- سأستقبل على جوالي فقط النتيجة ان كانت الرسالة تحوي على كلمات غير مرغوب بها أم لا
+حسناً ، فلنبدأ ;)
+استيراد المكتبات المناسبة في البداية
+ import urllib
+ from twilio.rest import Client
+
+كتابة دالتين def لتحقق من عملنا، +الأولى تدعى بـ read_text, والتي سوف تقرأ الملف المراد قراءته وفحصه.
+ def read_text():
+ quotes = open(r'C:\Users\2\Desktop\movie_quotes.txt','r')# قم بتغير هذا الكود بحسب مسار الملف المراد فحصه
+ contents_of_file = quotes.read()
+ #print (contents_of_file)
+ quotes.close()
+ check_profainty(contents_of_file)
+
+الثانية check profanity , والتي سوف تأخذ زمام الأمور لتنفيذ الأمر +الناتج عن قراءة الدالة الأولى read_text def.
+ def check_profainty(text_to_check):
+ account_sid = "ACdXXXXXXXXXXXXXXXX" #ادخل هذا الرقم من twilio
+ auth_token = "3bXXXXXXXXXXXXXXXXX" #ادخل هذا الرقم من twilio
+ client = Client(account_sid, auth_token)
+ connection = urllib.urlopen("http://www.wdylike.appspot.com/?q=" + text_to_check)
+ output= connection.read()
+ #print (output)
+ connection.close()
+
+ if "true" in output:
+ message = client.messages.create(
+ body="profainty Alert!",
+ to="+213xxxxxxxx", # ضع رقم هاتفك
+ from_="+143xxxxxxx") # ضع رقمك في موقع twilio
+ print(message.sid)
+
+ elif "false" in output:
+ message = client.messages.create(
+ body="This document has no curse words!",
+ to="+213xxxxxxxx", # ضع رقم هاتفك
+ from_="+143xxxxxxx") # ضع رقمك في موقع twilio
+ print(message.sid)
+
+ else:
+ message = client.messages.create(
+ body="Could not scan the document properly.",
+ to="+213xxxxxxxx", # ضع رقم هاتفك
+ from_="+143xxxxxxx") # ضع رقمك في موقع twilio
+ print(message.sid)
+
+الخطوة الأخيرة, ولكن في الواقع , هذه الخطوة الأولى, عندما تقوم بتشغيل البرنامج, +هذه الدالة سوف تبدأ بالعمل على استدعاء دالة read_text .
+ def see_me_that_in_phone():
+ x = read_text()
+
+دعونا نبدأ ;)
+ see_me_that_in_phone()
+
+
+ added by @Modydj +Python 2.7 +2 in 1 (Twilio + Profanity Editor)
+Mechanism of Action:
+2 - I will make it back to the functions (check_profainty, read_text)
+3 - Finally, I will receive on my mobile only the result if the message contains the words undesirable or not
+Well, Let's start:
+import the appropriate libraries in the first
+ import urllib
+ from twilio.rest import Client
+
+Write two def to check from our work, +The first one is read_text, which will read your target file.
+ def read_text():
+ quotes = open(r'C:\Users\Desktop\movie_quotes.txt','r')# Let's change this address according to your destination
+ contents_of_file = quotes.read()
+ #print (contents_of_file)
+ quotes.close()
+ check_profanity(contents_of_file)
+
+The second one is check profanity , which will take the order after knowing +the result by using read_text def.
+ def check_profanity(text_to_check):
+ account_sid = "ACdXXXXXXXXXXXXXXXX" #Enter your twilio account_sid
+ auth_token = "3bXXXXXXXXXXXXXXXXX" # Enter your twilio account_token
+ client = Client(account_sid, auth_token)
+ connection = urllib.urlopen("http://www.wdylike.appspot.com/?q=" + text_to_check)
+ output= connection.read()
+ #print (output)
+ connection.close()
+
+ if "true" in output:
+ message = client.messages.create(
+ body="profainty Alert!",
+ to="+213xxxxxxxx", # put your number phone
+ from_="+143xxxxxxx")# put your number phone on Twilio
+ print(message.sid)
+
+ elif "false" in output:
+ message = client.messages.create(
+ body="This document has no curse words!",
+ to="+213xxxxxxxx",# put your number phone
+ from_="+143xxxxxxx")# put your number phone on Twilio
+ print(message.sid)
+
+ else:
+ message = client.messages.create(
+ body="Could not scan the document properly.",
+ to="+213xxxxxxxx",# put your number phone
+ from_="+143xxxxxxx")# put your number phone on Twilio
+ print(message.sid)
+
+The last step, but in fact, this is the first step, when you run this program, +This def will start in the begging to summon read_text def.
+ def see_me_that_in_phone():
+ x = read_text()
+
+And here we go ;)
+ see_me_that_in_phone()
+
+
+ ajouté par @Modydj +Python 2.7 +2 en 1 ( Twilio + Profanity Éditeur)
+Mécanisme d'action:
+2 - Je vais revenir aux fonctions: (check_profainty, read_text)
+3 - Enfin, je recevrai sur mon portable le résultat si le message contient les mots indésirables ou non
+Bien, On y va ;)
+importer les bibliothèques appropriées dans le premier
+ import urllib
+ from twilio.rest import Client
+
+Ecrire deux def pour vérifier de notre travail, +Le premier est read_text, qui lira votre fichier cible.
+ def read_text():
+ quotes = open(r'C:\Users\Desktop\movie_quotes.txt','r')# Changeons cette adresse en fonction de votre destination
+ contents_of_file = quotes.read()
+ #print (contents_of_file)
+ quotes.close()
+ check_profanity(contents_of_file)
+
+Le second est de vérifier check_profanity, qui prendra l'ordre après avoir connu +le résultat en utilisant read_text def.
+ def check_profanity(text_to_check):
+ account_sid = "ACdXXXXXXXXXXXXXXXX" # Entrez votre twilio account_sid
+ auth_token = "3bXXXXXXXXXXXXXXXXX" # Entrez votre twilio account_token
+ client = Client(account_sid, auth_token)
+ connection = urllib.urlopen("http://www.wdylike.appspot.com/?q=" + text_to_check)
+ output= connection.read()
+ #print (output)
+ connection.close()
+
+ if "true" in output:
+ message = client.messages.create(
+ body="profainty Alert!",
+ to="+213xxxxxxxx", # mettez votre numéro de téléphone
+ from_="+143xxxxxxx")# mettez votre numéro de téléphone sur Twilio
+ print(message.sid)
+
+ elif "false" in output:
+ message = client.messages.create(
+ body="This document has no curse words!",
+ to="+213xxxxxxxx",# mettez votre numéro de téléphone
+ from_="+143xxxxxxx")# mettez votre numéro de téléphone sur Twilio
+ print(message.sid)
+
+ else:
+ message = client.messages.create(
+ body="Could not scan the document properly.",
+ to="+213xxxxxxxx",# mettez votre numéro de téléphone
+ from_="+143xxxxxxx")# mettez votre numéro de téléphone sur Twilio
+ print(message.sid)
+
+La dernière étape, mais en fait, c'est la première étape, lorsque vous exécutez ce programme, +Cette def commencera dans le begging pour invoquer read_text def.
+ def see_me_that_in_phone():
+ x = read_text()
+
+Et c'est parti ;)
+ see_me_that_in_phone()
+
+
+ what is python
+added by @Dima
+ print("What is Data Types?")
+
+ print("_______________________________________________________")
+
+
+ print("Collections of data put together like array ")
+
+ print("________________________________________________________")
+
+ print("there are four data types in the Python ")
+
+ print("________________________________________________________")
+
+ print("""1)--List is a collection which is ordered and changeable.
+ Allows duplicate members.""")
+ print("________________________________________________________")
+
+ print("""2)--Tuple is a collection which is ordered and unchangeable
+ Allows duplicate members.""")
+ print("________________________________________________________")
+
+ print("""3)--Set is a collection which is unordered and unindexed.
+ No duplicate members.""")
+ print("________________________________________________________")
+
+ print("""4)--Dictionary is a collection which is unordered,.""")
+
+
+
+ input("press close to exit")
+
+
+ from __future__ import print_function
+
+what is Functions
+added by @Dima
+ print("What is Functions?")
+
+ print("_______________________________________________________")
+
+
+ print(""" A function is a block of organized,
+ reusable code that is used to perform a single,
+ related action. Functions provide better
+ modularity for your application and a high
+ degree of code reusing""")
+
+ print("________________________________________________________")
+
+ input("press close to exit")
+
+
+ from __future__ import print_function
+
+what is python
+added by @Dima
+ print("What is OOP?")
+
+ print("_______________________________________________________")
+
+
+ print(""" combining data and functionality
+ and wrap it inside something called an object.
+ This is called the object oriented programming
+ paradigm. Most of the time you can use procedural
+ programming, but when writing large programs or have
+ a problem that is better suited to this method, you
+ can use object oriented programming techniques.""")
+
+ print("________________________________________________________")
+
+ print("***Classes***")
+
+ print("_______________________________________________________")
+
+
+ print(""" A user-defined prototype for an object
+ that defines a set of attributes that characterize
+ any object of the class.""")
+
+ print("________________________________________________________")
+
+ print("***objects****")
+
+ print("_______________________________________________________")
+
+
+ print("""objects are instances of the class""")
+
+ print("________________________________________________________")
+
+ print("**methods***")
+
+ print("_______________________________________________________")
+
+
+ print("""its a function, except that we have an extra self variable""")
+
+ print("________________________________________________________")
+
+ print("***Inheritance***")
+
+ print("_______________________________________________________")
+
+
+ print("""its a mechanism to reuse of code.
+ Inheritance can be best imagined as implementing
+ a type and subtype relationship between classes.""")
+
+ print("________________________________________________________")
+
+
+ input("press close to exit")
+
+
+ from __future__ import print_function
+
+what is python
+added by @Dima
+ print("What is Python?")
+
+ print("_______________________________________________________")
+
+
+ print(""" In technical terms,
+ Python is an object-oriented,
+ high-level programming language
+ with integrated dynamic
+ semantics primarily
+ for web and app development.
+ It is extremely attractive in the field of Rapid
+ Application Development
+ because it offers dynamic
+ typing and dynamic binding options""")
+
+ print("________________________________________________________")
+
+ input("press close to exit")
+
+
+ This project was created and maintained by students and tutors from (1 million arab coders initiative).
+Students from 22 arab countries add their python examples and tutorials to make an encyclopedia for Python language.
+The project is divided into categories , each category contains subcategories and examples for it in three different languages (English , Arabic and French).
+see the CONTRIBUTING.md file for details
+To See list of contributors check CONTIBUTORS.md file for details
+This project is licensed under the MIT License - see the LICENSE.md file for details
+ +Examples on how to uses Python Arithmetic Operators
+What is the operator in Python? +Operators are special symbols in Python that carry out arithmetic or logical computation. +The value that the operator operates on is called the operand. +for example: 2 + 3 = 5 +Here, + is the operator that performs addition. +2 and 3 are the operands and 5 is the output of the operation.
+what is Arithmetic Operators means ? + Operator | Description + ----------------------------------------------- + + Addition | Adds values on either side of the operator. + - Subtraction | Subtracts right hand operand from left hand operand. + * Multiplication | Multiplies values on either side of the operator + / Division | Divides left hand operand by right hand operand + % Modulus | Divides left hand operand by right hand operand and returns remainder + ** Exponent | Performs exponential (power) calculation on operators + // Floor Division | he division of operands where the result is the quotient in which the digits after the decimal point are removed. But if one of the operands is negative, the result is floored, i.e., rounded away from zero
+when do we use it ? +we use this kind of every where form basic math operation to loops or condition statements +''' +from future import print_function +a = 20 ; b = 10
+c = a + b +print("Addition value =" , c)
+c = a - b +print("Subtraction value = " , c)
+c = a * b +print("Multipliction value = " , c)
+c = a / b +print("Division value = " , c)
+c = a % b +print("Mod value = " , c)
+a = 2 ; b = 3 +c = a ** b +print("Exponent value = " , c)
+ Note :
+ In Python 3 the division of 5 / 2 will return 2.5 this is floating point division
+ the floor Division or integer divisio will return 2 mean return only the integer value
+
+a = 9 ; b = 4 +c = a // b +print("Integer Division value = " , c)
+ +