# -*- coding: utf-8 -*-
"""python_tutorials.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1g_zb5HaPKE7sIHHbijAya0aBnt08aaec

# Textual Data
"""

my_message = "Hello World"
print(my_message)

print(my_message.count('l'))

print(my_message.find('World'))

new_message = my_message.replace('World', 'Universe')
print(new_message)

name = 'Ramchandra'
surname = 'Joshi'

full_name = '{} {}'.format(name, surname)
print(full_name)

new_full_name = f'{name.upper()} {surname}'
print(new_full_name)

print(dir(name))

print(help(str))

print(help(str.lower))



"""# Numeric Data"""

print(3 / 2)
print(3 // 2)

print(3 * 2)
print(3 ** 2)

print(3 % 2)

num = 2
num *= 10
print(num)

print(abs(-3))

print(round(3.76))
print(round(2.22))

print(round(3.76, 1))

print(3 == 2)
print(3 != 2)

print(3 >= 2)
print(3 <= 2)

print(3 > 2)
print(3 < 2)

num1 = '100'
num2 = '200'

num1 = int(num1)
num2 = int(num2)

print(num1 + num2)



"""# Lists"""

courses = ['English', 'Maths', 'Science', 'History', 'Physics']
print(courses)
print(len(courses))

print(courses[-1])

print(courses[0:3])

print(courses[:3])
print(courses[1:])

courses.append('Arts')
courses.insert(1, 'Chemistry')
print(courses)

courses2 = ['Biology', 'CS']
courses.extend(courses2) # same as courses += courses2
print(courses)

courses.remove('Biology')
print(courses)

courses.reverse()
print(courses)

num_list = [1, 4, 3, 6, 2, -2, -6]
num_list.sort()
print(num_list)

num_list.sort(reverse=True)
print(num_list)

sorted_courses = sorted(courses)
print(sorted_courses)

print(min(num_list))
print(max(num_list))
print(sum(num_list))

print(courses.index('Maths'))

print('Maths' in courses)
print('Math' in courses)

for index, course in enumerate(courses, start=1):
  print(index, course)

course_str = ' , '.join(courses)
print(course_str)

new_list = course_str.split(' - ')
print(new_list)

"""# Tuples"""

list1 = ['Ram', 'Sairaj', 'Ganesh']
list2 = list1

list1[1] = 'Ruturaj'
print(list1)
print(list2)

tuple1 = ('Ram', 'Sairaj', 'Ganesh')
tuple1[1] = 'Ruturaj'
print(tuple)

"""# Sets"""

set_courses = {'English', 'Maths', 'Maths', 'Science', 'Physics'}
print(set_courses)
print(len(set_courses))

set_courses2 = {'English', 'Maths', 'Science', 'History', 'Design'}
print(set_courses2)

print(set_courses.intersection(set_courses2))
print(set_courses.union(set_courses2))
print(set_courses.difference(set_courses2))

"""# Empty Lists, Tuple and Sets"""

empty_list = []
empty_list = list()

empty_tuple = ()
empty_tuple = tuple()

empty_set = {} # This would create an empty dictionary and not an empty set
empty_set = set()

"""# Dictionary"""

student = {'name': 'Ram', 'age': 21, 'courses': ['A', 'B']}
print(student)

print(student.get('name'))

print(student.get('phone'))
print(student.get('phone', 'Not Found'))

student['phone'] = 11111
student['name'] = 'Ramchandra'
print(student)

student.update({'name': 'RJ', 'age': 22})
print(student)

del student['age']
print(student)

student_name = student.pop('name')
print(student_name)
print(student)

print(len(student))

print(student.keys())
print(student.values())
print(student.items())

for key in student:
  print(key)

for key, value in student.items():
  print(key, value)

"""# Conditions and Booleans"""

language = 'Python'

if language == 'Java':
  print('Java')
elif language == 'Python':
  print('Python')
else:
  print('Different Language')

user = 'Admin'
logged_in = True

if user == 'Admin' and logged_in:
  print('Admin Page')
else:
  print('Not Admin')

logged_in = False

if not logged_in:
  print('Please Log In')
else:
  print('Welcome')

a = [1, 2, 3]
b = [1, 2, 3]

print(a == b)
print(a is b)

print(id(a))
print(id(b))

a[0] = 5
print(a)
print(b)

a = [1, 2, 3]
b = a

print(a == b)
print(a is b)

print(id(a))
print(id(b))

a[0] = 5
print(a)
print(b)

# False Values
# False
# None
# Zero of any numeric value
# Any Empty Sequence : '', (), []
# Any Empty Mapping : {}

"""# Loops and Iterations"""

nums = [1, 2, 3, 4, 5]
for num in nums:
  print(num)

for num in nums:
  if num == 3:
    print('Found')
    break
  print(num)

for num in nums:
  if num == 3:
    print('Found')
    continue
  print(num)

for num in nums:
  for letter in 'abc':
    print(num, letter)
  print('---')

for i in range(1, 11):
  print(i)

x = 0

while (x < 10):
  print(x)
  x += 1

"""# Functions"""

def hello_func():
  pass

print(hello_func)
print(hello_func())

# Function is DRY (Don't Repeat Yourself)
def hello_func():
  print('Hello Function')

hello_func()

def function_args(age, name='Ram'):
  return 'Hi {} {}'.format(name, age)

print(function_args(21, 'Ganesh'))

print(function_args(21))

def function(*args, **kwargs):
  print(args)
  print(kwargs)

function('Math', 'Arts', name='Ram', age=21)

courses = ['Math', 'Arts']
info = {'name':'Ram', 'age':21}

function(courses, info)

function(*courses, **info)

