python exercises code example

Example 1: python beginner practice problems

1,000+ Python Practice Challenges // Edabit
go to : https://edabit.com/challenges/python3

Example 2: python function exercises

Exercise 1: Create a function that can accept two arguments name and 
  age and print its value
Exercise 2: Write a function func1() such that it can accept a variable 
  length of  argument and print all arguments value
Exercise 3: Write a function calculation() such that it can accept two 
  variables and calculate the addition and subtraction of them. And a
  lso it must return both addition and subtraction in a single return 
  call
Exercise 4: Create a function showEmployee() in such a way that it 
  should accept employee name, and its salary and display both. 
  If the salary is missing in the function call assign default value 
  9000 to salary
Exercise 5: Create an inner function to calculate the addition in the 
  following way
Exercise 6: Write a recursive function to calculate the sum of numbers 
  from 0 to 10
Exercise 7: Assign a different name to function and call it through the 
  new name
Exercise 8: Generate a Python list of all the even numbers between 4 to 
  30
Exercise 9: Return the largest item from the given list
  
⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️ GOTO URL FOR PRACTICE ⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️⤵️
https://pynative.com/python-functions-exercise-with-solutions/

Example 3: python practice problems

Solve Python | HackerRank

Go to : https://www.hackerrank.com/domains/python

Example 4: python exercises with solutions init method

>>> class Triangle(object):
...     def __init__(self,angle1,angle2,angle3):
...         self.angle1=angle1
...         self.angle2=angle2
...         self.angle3=angle3
...
...     number_of_sides=3
...     def check_angles(self):
...         if self.angle1+self.angle2+self.angle3 ==180:
...             return True
...         else:
...             return False
...
>>> class Equilateral(Triangle):
...   angle = 60
...   def __init__(self):
...        self.angle1 = self.angle2 = self.angle3 = self.angle
...
>>> my_triangle=Triangle(90,30,60)
>>>
>>> print my_triangle.number_of_sides
3
>>> print my_triangle.check_angles()
True
>>>

>>>