-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsandbox.py
More file actions
executable file
·45 lines (38 loc) · 1.37 KB
/
Copy pathsandbox.py
File metadata and controls
executable file
·45 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python -tt
"""
Just my sandbox code to test out Python stuff
"""
import sys
from typing import Any, Generator
import numpy as np
def numpy_increasing_array_test(x,y):
list_ = [[xi*y+ yi for yi in range(y)] for xi in range(x)] # We use `list_` instead of
# `list` here so that the variable name does not shadow the built-in name 'list'
array_ = np.array(list_)
print(array_)
print(array_.shape)
print(array_.dtype)
# Define the generator function for Fibonacci
def fibonacci(n: object) -> Generator[int | Any, Any, None]:
count = 1
a, b = 0, 1
while count <= n:
yield a
a, b = b, a + b
count += 1
# Write a generator expression that takes a string and returns a new string with only the vowels.
def genvowels(string: object) -> Generator[Any, Any, None]:
vowels = {"a", "e", "i", "o", "u"}
for c in string:
if c in vowels:
yield c
# Define a main() function that prints extracted vowels.
def main():
istr = input("Type your String for vowel extraction: ")
vowels = "".join(genvowels(istr)) # Collect generator output
print(f"Extracted vowels: {vowels}") # Print result
# This is the standard boilerplate that calls the main() function.
if __name__ == "__main__":
print("Running main")
print(f"Sys Paths: {sys.path}")
numpy_increasing_array_test(4,9)