diff --git a/Modules/numpy_en.py b/Modules/numpy_en.py new file mode 100644 index 0000000..8bde5f9 --- /dev/null +++ b/Modules/numpy_en.py @@ -0,0 +1,50 @@ +#example 3 +#added by @sagarbabalsure +#This example show the some operations using numpy package. + + +import numpy as np + +#basics + +a=np.array([[1,2,3], + [4,5,6]]) +print(type(a)) +print(np.ndim(a)) +print(np.size(a)) +print(a.dtype) +print(a.shape) +#array creation +a=np.array((2,4,6)) +print(a) +b=np.zeros((3,4),dtype='int') +print(b) +c=np.ones((2,2)) +print(c) +d=np.full((3,3),4) +print(d) +e=np.arange(0,30,5) +print(e) +f=np.random.random((2,2)) +print(f) +g=np.linspace(0,10,5,dtype='int') +print(g) + +#array indexing +x=np.array([[1,2,3],[2,3,4],[1,4,7]]) +t=x[:2,:2] +print(t) +t=x[[0,0]] +print(t) +t=x[[1,2],[1,0]] +print(t) + +#operations +print(x+2) +print(x*3) +print(x) +print("transpose: ",x.T) +print("multiplication",a.dot(x)) +print(x.max()) +print(x.sum()) +print(np.sort(x)) diff --git a/Modules/qr_en.py b/Modules/qr_en.py new file mode 100644 index 0000000..57b1f85 --- /dev/null +++ b/Modules/qr_en.py @@ -0,0 +1,13 @@ +#example 1 +#added by @sagarbabalsure +#This example create the "QR CODE" for entered string and make the file 'myqr.svg' in your present folder. +#By scanning this qrcode you can go to that url + + + + +import pyqrcode +from pyqrcode import QRCode +s=raw_input("Enter any url to make qr code: ") +url=pyqrcode.create(s) +url.svg("myqr.svg",scale=8) diff --git a/Modules/random_number_en.py b/Modules/random_number_en.py new file mode 100644 index 0000000..58d7019 --- /dev/null +++ b/Modules/random_number_en.py @@ -0,0 +1,21 @@ +#example 2 +#added by @sagarbabalsure +#This example is like guess game.Where user try to guess the randomly generated number in three trials. + + +import string +import random +from random import randint +x = randint(1, 100) +print(x) +count=3 +while count>0: + y=int(input("Enter your guess: ")) + count=count-1 + if x==y: + print("Oh..your guess is correct") + else: + print("you have %d guesses remaining" %(count)) + if count==0: + print("sorry you lose") + diff --git a/README.md b/README.md index f8d05ac..53a9dad 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Students from 22 arab countries add their python examples and tutorials to make ## Getting Started -The project is divided into categories , each category contains subcategories and examples for it in three different languages (English , Arabic and French). +The project is divided into various categories and each category contains subcategories and examples for it in three different languages (English , Arabic and French).