-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b0ca356
Showing
9 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
res1 = print('Hi') | ||
res2 = int('2') | ||
res3 = sum([1, 2, 3]) | ||
res4 = 'hi'.upper() | ||
|
||
print('res1', res1, type(res1)) | ||
print('res2', res2, type(res2)) | ||
print('res3', res3, type(res3)) | ||
print('res4', res4, type(res4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# from datetime import datetime | ||
|
||
|
||
def print_hello(): | ||
print('Hello') | ||
|
||
|
||
|
||
|
||
############################################################################ | ||
|
||
|
||
# def get_current_time(): | ||
# return datetime.now().strftime('%H:%M') | ||
|
||
# get_current_time() | ||
|
||
|
||
############################################################################ | ||
|
||
|
||
# res1 = print_hello() | ||
# res2 = get_current_time() | ||
|
||
# print('res1', res1, type(res1)) | ||
# print('res2', res2, type(res2)) | ||
|
||
|
||
############################################################################ | ||
|
||
|
||
# def int_input(): | ||
# while(True): | ||
# res = input('Enter a number: ') | ||
# if res.isdigit(): | ||
# return int(res) | ||
# else: | ||
# print('It\'s not a number') | ||
|
||
|
||
# res1 = int_input() | ||
# print(res1) | ||
|
||
|
||
############################################################################ | ||
|
||
# test_func() | ||
|
||
# def test_func(): | ||
# pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
def greet(name): | ||
print(f'Hello, {name}. How are you?') | ||
|
||
|
||
greet('Bob') | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def bread_factory(num): | ||
# return '🍞' * num | ||
|
||
|
||
# for i in range(1, 10): | ||
# print(bread_factory(i)) | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def func1(f_name, l_name): | ||
# print(f'Hello, {f_name} {l_name}') | ||
|
||
# func1('Bob', 'Marley') | ||
# func1('Bob') | ||
# func1('Bob', 'Marley', 'Marley') | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def func2(country="Norway"): | ||
# print("I am from " + country) | ||
|
||
|
||
# func2("Sweden") | ||
# func2() | ||
# func2("Brazil") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
def func1(a, b, c): | ||
print(a, b, c) | ||
print(a + b + c) | ||
|
||
|
||
func1(a=1, b=2, c=3) | ||
func1(c=3, b=2, a=1) | ||
|
||
# func1(1, b=2, c=3) | ||
# func1(a=1, 2, 3) | ||
|
||
# func1(c=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
def func1(*langs): | ||
print(langs, type(langs)) | ||
print("The oldest language is " + langs[1]) | ||
|
||
|
||
def func2(*langs): | ||
for i in range(len(langs)): | ||
print("The best language is " + langs[i]) | ||
|
||
|
||
func1("C++", "JS", "Python") | ||
func2("C++", "JS", "Python") | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# langs = ["C++", "JS", "Python"] | ||
|
||
# def func3(langs): | ||
# for i in range(len(langs)): | ||
# print("The best language is " + langs[i]) | ||
|
||
# func3(langs) | ||
|
||
################################################################ | ||
|
||
|
||
# func1(langs) | ||
# func2(langs) | ||
|
||
|
||
# name = ['Bob', 'Marley'] | ||
|
||
|
||
# def func4(f_name, l_name): | ||
# print(f'Hello, {f_name} {l_name}') | ||
|
||
|
||
# func4(*name) | ||
|
||
################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
def func1(**details): | ||
print(details, type(details)) | ||
|
||
for key, value in details.items(): | ||
print("{}: {}".format(key, value)) | ||
|
||
|
||
func1(Name="val_Name", Project="val_Project", Number="val_Number") | ||
|
||
# func1(a=1, b=2) | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def func2(*members, **features): | ||
# for member in members: | ||
# print(member) | ||
|
||
# for key, value in features.items(): | ||
# print("{}: {}".format(key, value)) | ||
|
||
|
||
# func2("Bob", "Marley", Name="val_Name", | ||
# Project="val_Project", Number="val_Number") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import math | ||
|
||
|
||
x = lambda a: a + 10 | ||
print(x(5)) | ||
|
||
x = lambda a, b: a * b | ||
print(x(5, 6)) | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def emoji_factory(emoji): | ||
# return lambda n: n * emoji | ||
|
||
|
||
# bread_factory = emoji_factory('🍞') | ||
# breads = bread_factory(5) | ||
# print(breads) | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def createLog(base): | ||
# return lambda n: math.ceil(math.log(n, base)) | ||
|
||
|
||
# lg10 = createLog(10) | ||
# lg2 = createLog(2) | ||
# ln = createLog(math.e) | ||
|
||
# print('lg10(100)', lg10(100)) | ||
# print('lg10(1000)', lg10(1000)) | ||
|
||
# print('lg2(8)', lg2(8)) | ||
# print('lg2(16)', lg2(16)) | ||
|
||
# print('ln(1)', ln(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from datetime import datetime | ||
|
||
|
||
def greet(name): | ||
""" | ||
This function greets to | ||
the person passed in as | ||
a parameter | ||
Parameters: | ||
name(str): Name of user | ||
Returns: | ||
None | ||
""" | ||
print(f'Hello, {name}. How are you?') | ||
|
||
|
||
# help(greet) | ||
# print(greet.__doc__) | ||
################################################################ | ||
|
||
|
||
# def say_time(): | ||
# ''' | ||
# Print current time | ||
# :return: None | ||
# ''' | ||
# print(datetime.now().strftime('%H:%M')) | ||
|
||
|
||
# say_time() | ||
# 'q' key for exit | ||
# help(say_time) | ||
|
||
|
||
################################################################ | ||
|
||
|
||
# def get_time(): | ||
# ''' | ||
# Generate time in HH:MM format | ||
# :return: String | ||
# ''' | ||
# return datetime.now().strftime('%H:%M') | ||
|
||
|
||
# get_time() | ||
# help(get_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# **Functions** | ||
|
||
## Links: | ||
- https://www.programiz.com/python-programming/function | ||
- https://www.educative.io/edpresso/what-are-keyword-arguments-in-python | ||
- https://www.w3schools.com/python/python_functions.asp | ||
- https://www.w3schools.com/python/python_lambda.asp | ||
- https://www.datacamp.com/community/tutorials/docstrings-python | ||
|
||
## Exercises: | ||
- [1](https://www.w3schools.com/python/exercise.asp?filename=exercise_functions1) | ||
- [Quiz](https://pynative.com/python-functions-quiz/) | ||
- [2](https://pynative.com/python-functions-exercise-with-solutions/#h-exercise-1-create-a-function-in-python) | ||
- [3](https://erlerobotics.gitbooks.io/erle-robotics-learning-python-gitbook-free/content/functions/exercises_functions.html) | ||
- [Lambdas](https://www.w3schools.com/python/exercise.asp?filename=exercise_lambda1) | ||
- [Only for teacher](http://hplgit.github.io/bumpy/doc/pub/sphinx-basics/._basics005.html#exercise-1-program-a-formula) | ||
--- | ||
*24.01.2022 - Odesa* |