Skip to content

Commit ed4e496

Browse files
committed
Added two random function
1 parent fde74a4 commit ed4e496

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

examples/intro.ipynb

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "06cd51ed",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import mapvu"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 5,
16+
"id": "86fe4d32",
17+
"metadata": {},
18+
"outputs": [
19+
{
20+
"data": {
21+
"text/plain": [
22+
"'xtlsyqvxhy'"
23+
]
24+
},
25+
"execution_count": 5,
26+
"metadata": {},
27+
"output_type": "execute_result"
28+
}
29+
],
30+
"source": [
31+
"mapvu.generate_random_string(10)"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 3,
37+
"id": "8cc4f0f5",
38+
"metadata": {},
39+
"outputs": [
40+
{
41+
"data": {
42+
"text/plain": [
43+
"50"
44+
]
45+
},
46+
"execution_count": 3,
47+
"metadata": {},
48+
"output_type": "execute_result"
49+
}
50+
],
51+
"source": [
52+
"mapvu.generate_lucky_number(2)"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": null,
58+
"id": "cc74a4a3",
59+
"metadata": {},
60+
"outputs": [],
61+
"source": []
62+
}
63+
],
64+
"metadata": {
65+
"kernelspec": {
66+
"display_name": "geos",
67+
"language": "python",
68+
"name": "python3"
69+
},
70+
"language_info": {
71+
"codemirror_mode": {
72+
"name": "ipython",
73+
"version": 3
74+
},
75+
"file_extension": ".py",
76+
"mimetype": "text/x-python",
77+
"name": "python",
78+
"nbconvert_exporter": "python",
79+
"pygments_lexer": "ipython3",
80+
"version": "3.9.23"
81+
}
82+
},
83+
"nbformat": 4,
84+
"nbformat_minor": 5
85+
}

mapvu/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
__author__ = """Atul Bhardwaj"""
44
__email__ = 'atulmncfc@gmail.com'
55
__version__ = '0.0.2'
6+
7+
from .mapvu import *

mapvu/mapvu.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
"""Main module."""
2+
3+
import string
4+
import random
5+
6+
def generate_random_string(length=10, upper=False, digits=False, punctuation=False ):
7+
letters = string.ascii_lowercase
8+
if upper:
9+
letters += string.ascii_uppercase
10+
if digits:
11+
letters += string.digits
12+
if punctuation:
13+
letters += string.punctuation
14+
result_str = ''.join(random.choice(letters) for i in range(length))
15+
return result_str
16+
17+
18+
def generate_lucky_number(length=1):
19+
result_str = '' .join(random.choice(string.digits) for i in range(length))
20+
return int(result_str)

0 commit comments

Comments
 (0)