Introducing Graphics (turtle module) part-2

Python Graphics !!

In this article we will continue about  graphics in python with the help of turtle module.


Turtle Module :

This module is specially destined to introduce graphics in the programming so user can perform graphical programs it includes all the functions of the drawing and so user can make desired graphical design .


Introducing Graphics (turtle module) part-1

Python Graphics !!


In this article we will discuss about introducing graphics in python with the help of turtle module.


Introduction :



 With the help of graphics module turtle we can able to make any design or any geometry. 


Turtle Module :

This module is specially destined to introduce graphics in the programming so user can perform graphical programs it includes all the functions of the drawing and so user can make desired graphical design .


Basic Functions :

Draw and Move Functions :
  • forward() or fd()

          It is used for moving the turtle forward.
            Ex- forward(50) , fd(50)

  • backward() or bk() or back()

         It is used for moving the turtle backward.
            Ex- backward(50) , bk(50), back(50)

  • right() or rt()

         It is used to turn  the turtle right.
            Ex- right(90) , rt(90)

  • left() or lt()

          It is used to turn  the turtle left.
            Ex- left(90) , lt(90)

  • setposition() or setpos()

          It is used to set the position of the turtle.
          we have to give two arguments to the function.
          (x,y) value of both x and y,
          Ex- setposition(10,20) , setpos(20,-10)

  • goto()
        It is used to send the turtle to the given coordinates.
        we have to pass the value of X and Y.
        Ex- goto(10,5)
  • setx()
       It is used to set the position of the x.
       Ex- setx(4)
  • sety()
       It is used to set the position of the y.
       Ex- sety(8)
  • home()
       It is used to send the turtle to the origin(0,0).
       Ex - home()
  • dot()
       It is used to create the dot of given arguments.
       we have to give two argument size and color of the dot.
       Ex-dot(10,"red")

  • speed()
        it is used for setting the speed of the turtle.
        0- highest speed of the turtle.
        10 - high speed of the turtle.
        1- slowest speed of the turtle.
        Ex- speed(0)


Tell State Of Turtle :

  •  posittion() or pos()
         It returns the coordinates of the turtle.
         Ex- position() or pos()
                >>(1,2,1).
  • xcor()
         It returns the value of x coordinate.
         Ex- xcor()
               >>10.
  • ycor()
        It returns the value of the y coordinate.
        Ex-ycor()
            >>5.
  • distance()
         It returns the distance of the coordinate from the origin.
         Ex- distance(6,8)
               >>10

Sample Programs Using Basic Functions 

  • Program to draw a square  
              import turtle


               for i in range (4):
                       turtle.fd(100)
                       turtle.rt(90)

             turtle.mainloop()


     - Output 



  • Program to make a circle 

          import turtle

          for i in range (360):
                 turtle.fd(2)
                 turtle.rt(1)

          turtle.mainloop()


        - Output 


  • Program to make polygon of n side
            import turtle
            n=int(input("enter no of side "))
            a =((n-2)*180)/n

           for i in range (n):
                   turtle.fd(50)
                   turtle.lt(180-a)

          turtle.mainloop()
     

        - Outputs 
           
         With input of 3

         With input of 5


         With input of 8
          
  • Program to draw the circle of desired radius with circle
          import turtle
          n=int(input("enter the radius "))    
          turtle.circle(n)                                                     #circle with radius n
          turtle.pu()                                                            #pen up
          turtle.setpos(turtle.xcor(),turtle.ycor()+n)          #to set the center of the circle
          turtle.pd()                                                           #pen up
          turtle.dot(20,"blue")                                           #for center  
          turtle.mainloop()

         - Output 
  • Program to make a circular ring 
            import turtle
            for i in range(40):
                  turtle.circle(10)
                  turtle.fd(10)
                  turtle.right(10)
            turtle.mainloop()

          -Output 

Machine Learning Jobs For Freshers

Machine Learning Jobs For Freshers

Machine Learning Fresher Jobs :

Computer Science Fundamentals and Programming:


Having a Computer Science background is very important to have a rewarding career in Machine Learning. Engineers looking for Machine Learning Jobs in India should have in-depth knowledge of data structures (stacks, queues, multi-dimensional arrays, trees, graphs, etc.), algorithms (searching, sorting, optimization, dynamic programming, etc.), computability and complexity (P vs. NP, NP-complete problems, big-O notation, approximate algorithms, etc.), and computer architecture (memory, cache, bandwidth, deadlocks, distributed processing, etc.). One must be able to apply, implement, adapt or address them when programming.

Machine Learning Algorithms and Libraries:


Candidates looking forward to Machine Learning jobs in India should be well acquainted with standard implementations of Machine Learning algorithms, most of which are widely available through libraries/packages/APIs .one should also be aware of the relative advantages and disadvantages of different approaches.



Probability and Statistics:


If you are looking for a career in Machine Learning, you should possess strong knowledge of formal characterization of probability and techniques derived from it (Bayes Nets, Markov Decision Processes, Hidden Markov Models, etc.). Also, knowledge of analysis methods (ANOVA, hypothesis testing) is necessary for building and validating models from observed data.

Software Engineering and System Design:


Having a strong base in software engineering and system design is required for a promising career in Machine Learning and data science. It also adds on to your Machine Learning skills. You should be able to build appropriate interfaces for your component. Having a good knowledge of Software engineering best practices (including requirements analysis, system design, modularity, version control, testing, documentation, etc.) are invaluable for productivity, collaboration, quality, and maintainability.


Recommended Articles :

Machine Learning Job Roles :


Machine Learning jobs in India and abroad include Machine Learning Engineer, Data Architect, Data Scientist, Data Mining Specialists, Cloud Architects, and Cyber Security Analysts, and many more. Let us take a sneak peek into some of the ML job roles in demand.  Machine Learning Jobs for freshers may include the job of a data analyst or data scientist.

Machine Learning Engineer:


A Machine Learning Engineer creates amazing algorithms to help decipher meaningful patterns from humongous amounts of data. ML Engineers should focus on Python, Java, Scala, C++, and JavaScript. He must be capable of building highly-scalable distributed systems and work in teams that focus on personalization. Machine Learning engineers have to design and implement Machine Learning applications/algorithms such as clustering, anomaly detection, classification, or prediction to address business challenges.

Data Analytics Course by Digital Vidya

Data Engineer/Data Architect:


Data Engineers are responsible for the organization’s big data ecosystem. With a strong foundation in programming, they must be familiar with Hadoop, MapReduce, Hive, MySQL, Cassandra, MongoDB, NoSQL, SQL, Data streaming, and programming. In addition, they must also be proficient in R, Python, Ruby, C++, Perl, Java, SAS, SPSS, and Matlab. Data infrastructure engineers develop, construct, test, and maintain highly scalable data management systems. Data Engineers also develop custom analytics applications and software components. Data engineers collect and store data, do real-time or batch processing, and serve it for analysis to data scientists via an API.

Data Scientist:


One of the most in-demand professionals today, Data Scientists are experts in R, SAS, Python, SQL, MatLab, Hive, Pig, and Spark. They are proficient in Big Data technologies and analytical tools. They use coding to sift through large amounts of unstructured data to derive insights and help design future strategies. Data scientists clean, manage and structure big data from disparate sources.

Data Analyst:


Most organizations expect Data Analysts to be familiar with data retrieval and storing systems, data visualization and data warehousing using ETL tools, Hadoop-based analytics, and business intelligence concepts. These persistent and passionate data miners usually have a strong background in math, statistics, Machine Learning, and programming. Core responsibilities of a Data Analyst include designing and deploying algorithms, culling information and recognizing risk, extrapolating data using advanced computer modeling, triaging code problems, and pruning data.

Machine Learning Jobs Salary :


The Indian Data Analytics Industry, with its current worth of $2 billion is expected to witness a whopping eight-fold growth and to be worth $16 billion by 2025, according to NASSCOM. Furthermore, the study indicates that the median salary of analytics professionals is growing year on year. The average salary of Data Science professionals across all skill sets and experience levels was ₹ 12.7L in 2017, an 8% increase since 2016, on a much larger base of professionals. The salary for Machine Learning Jobs for Freshers may start at ₹ 8L and may go up to ₹10-15 L.

You May Also Like This Article :


Machine Learning Jobs_salary :


According to the latest industry estimates, an AI professional with an experience of 2-4 years can earn annually ₹15-₹20 lakh ($20.6-27.5K). Experienced professionals with 4-8 years can expect up to ₹20-₹50 lakh ($20.6-68.8K). The salaries may vary from company to company. Top notch companies like Amazon India, Google, and Flipkart are ready something between 8-12 L per annum.  Most AI and Machine Learning are concentrated in IT, FinTech and e-commerce, as they rely on analytics, business intelligence and cloud for industrial automation.

Machine Learning Jobs Salary in India :

      
According to Ravi Kaklasaria, CEO& Co-Founder, SpringPeople, a corporate training and certification provider, India has over 50,000 open data analytics jobs on the market and expects the numbers to grow up to 100,000 in 2018. BN Thammaiah, Managing Director, Kelly Services India expects a 60% increase in demand for AI and Machine Learning specialists in 2018. The increase in the demand for AI and ML specialists will be from 20,000 to 32,000 in 2018 even as the IT sector will continue to hire for newer skills, he added further.

As per Analytics India Magazine ‘Salary Study – 2018 that explores a range of current and emerging compensation trends in the Analytics & Data Science space across India, observes that nearly 40% analytics professionals earn an annual salary upwards of ₹10L. In 2018, 37.6% of Analytics professionals in India received a salary of fewer than 6 Lakhs, compared to 39% in 2017 (39%) and 42% in 2016.

Mid-level analytics professionals are now progressing towards a higher salary bracket of ₹ 15 to 25L by having proper machine learning requirements. While the number of Analytics professionals commanding salaries less than ₹ 10 Lakhs has gone down; the number of Analytics professionals earning more than ₹ 15L has increased from 17% in 2016 to 21% in 2017 to 22.3% in 2018.

Mumbai leads in terms of highest compensation packages for Machine Learning jobs in India, at almost 13.3L per annum. Machine Learning jobs in Bangalore follow close quarters, with 12.5L and NCR at 11.8L. Data professionals looking for Machine Learning jobs in Pune can expect something around ₹ 10.6L. Salary packages for Machine Learning jobs in Hyderabad are comparatively, at ₹ 10.2L per annum.

The Future of Machine Learning :


The future of Machine Learning looks promising. There is an urgent need for professionals who are trained in Deep Learning and AI jobs and matches machine learning requirements. If you want to be one of those professionals, prepare yourself by getting certified and industry-ready because the sooner you get your training started, the sooner you will be working in this exciting and rapidly changing field.

You might be a programmer, a mathematics graduate, or simply a bachelor of Computer Applications. Students with a master’s degree in Economics or Social Science can also be an ML professional. Take up a Data Science or Data Analytics course, to learn Data Science and Machine Learning skills and not only prepare you for the Machine Learning job, but also gives a proper overview of all the machine learning requirements.

data-analytics-certification-course :


You may also enroll in Machine Learning Course for more lucrative career options in Data Science.  Industry-relevant curriculums, pragmatic market-ready approach, hands-on Capstone Project are some of the best reasons for choosing Digital Vidya.

For a rewarding career in Machine Learning, one must stay up to date with any up and coming changes in the machine learning requirements. This also means staying abreast of the latest developments for tools (changelog, conferences, etc.), theory and algorithms (research papers, blogs, conference videos, etc.).

Online communities are great places to know about these changes. Also, read a lot: read articles on Google Map-Reduce, Google File System, Google Big Table, and The Unreasonable Effectiveness of Data. You will get plenty of free Machine Learning books online. Practice problems, coding competitions, and hackathons are a great way to hone your machine learning skills

Machine Learning , Machine Learning Is , What Machine Learning , Machine Learning In Python , Machine Learning Python , Machine Learning With Python ,  Python With Machine Learning , Machine Learning Algorithms , Machine Learning Engineer , Machine Learning VS AI , Machine Learning vs Deep Learning , Machine Learning Andrew ng , Machine Learning by Andrew ng , Machine Learning Engineer Salary , Machine Learning Course , Machine Learning Google , Machine Learning On aws , Machine Learning Jobs , Machine Learning Definition , Machine Learning Reddit , Machine Learning Interview Questions , Machine Learning Tutorial , Machine Learning Models , Machine Learning With r , Machine Learning Book , Machine Learning Introduction , Machine Learning Examples , Machine Learning vs Artificial Intelligence , Machine Learning Stanford , Machine Learning Certification , Machine Learning Applications , Machine Learning Datasets , Machine Learning Best Books , Machine Learning Projects , Machine Learning Types , Machine Learning Internship , Machine Learning Healthcare , Machine Learning In Healthcare , Machine Learning Basics , Machine Learning Udacity , Machine Learning Decision Tree , Machine Learning Crash Course , Machine Learning Library Python , Machine Learning Salary , Machine Learning For Dummie , Machine Learning Mathematics , Machine Learning In Finance , Machine Learning Online Course , Machine Learning Tool AI , Machine Learning Course Online , Machine Learning Tools , Machine Learning NLP , Machine Learning MIT , Machine Learning Neural Networks , Machine Learning With Java , Machine Learning vs Data Science , Machine Learning Regression , Machine Learning Mastery , Machine Learning And Artificial Intelligence , Machine Learning Techniques , Machine Learning Tutorial Python , Machine Learning With Python Tutorial , Machine Learning Language , Machine Learning pdf , Machine Learning Udemy , Machine Learning With Tensorflow , Machine Learning Linear Regression , Machine Learning Yearning , Machine Learning Training

Python Constructor !!

Python Constructor !!




In this article we will discuss about constructors and types of constructor in python.

Constructor


Constructor is a special function which name is used to initialize the instance member of the class.

Constructor is execute when object of the class is created.

Types Of Constructor


  • Parameterized Constructor
  • Non-parameterized Constructor

Create Constructor


Constructor created in python with _init_ method.

We can give any number of arguments in constructor.


Non Parameterized Constructor


If there is no arguments in constructor then it is non perameterized constructor.

When instance of class created  constructor invoke automatically.

Program :


Output :

This is non parameterized constructor
Hello Nibkarma

Parameterized Constructor


If there is arguments in constructor then it is perameterized constructor.

When we pass number of arguments in the constructor then constructor invoke automatically.
Program :


Output :


This is parameterized constructor
Hello Nibkarma

In this article we discuss about Constructor and types of constructor in brief.For more interesting articles keep join us!!

Basic Programs Of All Python Methods


1) Program :


Python program to print Hello World.

# This prints Hello World on the output screen
print('NibKarma')

Output :


Hello NibKarma

List Programs

2) Program :



def string_length(str):
    count = 0
    for char in str:
        count += 1
    return count
print(string_length('NibKarma'))


Output : 8

Python Dictionary

3) Program :


def char_frequency(str):
    dict = {}
    for n in str:
        keys = dict.keys()
        if n in keys:
            dict[n] += 1
        else:
            dict[n] = 1
    return dict
print(char_frequency('NibKarma'))

Output :


{'a': 2, 'N': 1, 'i': 1, 'K': 1, 'r': 1, 'm': 1}

Python Tuple 

4) Program :

tuple=('a','b','c','d','e')
print(tuple)
del tuple[1]
print(tuple)

Output :


('a', 'b', 'c', 'd', 'e')

5) Program :



a = "Hello world"
print(a)
print(a[0])
print(a[1])
print(a[2])

x = "Hello"
y = "Khush"
print(x+y)

s = "Hello Khush"
print(s[0:2])
print(s[2:7])
print(s[4:])

Output :


Hello world
H
e
l
HelloKhush
He
llo K
o Khush

Python Pass

6) Program :


l=[1,2,3,4,5]
for i in l:
    if i==3:
        pass
        print ("Pass execute")
        print("Hello khush")
    print(i)

Output :


1
2
Pass execute
Hello khush
3
4
5

Python List

7) Program :



a1=["khush","jinu","ashu","shwetu"]
print(a1)
a3=['a','b','c']
print(a3)
a5=[1,2,3]
print(a5)
a6=[1,'khush']
print(a6)


a=['a','b','c','d','e']
print(a)
a[2]=3
print(a)
a[1:3]=1,2
print(a)
a[0:]=1,2,3,4,5
print(a)
del a[1]
print(a)

n=["khush","nishu","priti"]
print(n)
n.append("jinu")
print(n)
n.insert(2,"siya")
print(n)

n=["khush","nishu","priti"]
print(n)
n.remove("nishu")
print(n)
n.remove(n[0])
print(n)

n=[1,2,3,4,5]
print(n)
print("length is "+str(len(n)))

n=[1,2,3,4,5]
for i in n:
    print(i)

a=["khush","keri","ketan","khushi"]
print(a)
print("after sorting :")
a.sort()
print(a)

a=["khush","keri","ketan","khushi"]
print(a)
print("after reverse :")
a.reverse()
print(a)

a=["khush","keri","ketan","khushi"]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)

print("maximum and minimum in numbers")

a=[1,2,3,4,5]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)

a=[1,2,3,4,5]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)
a.clear()
print(a)


Output :


['khush', 'jinu', 'ashu', 'shwetu']
['a', 'b', 'c']
[1, 2, 3]
[1, 'khush']
['a', 'b', 'c', 'd', 'e']
['a', 'b', 3, 'd', 'e']
['a', 1, 2, 'd', 'e']
[1, 2, 3, 4, 5]
[1, 3, 4, 5]
['khush', 'nishu', 'priti']
['khush', 'nishu', 'priti', 'jinu']
['khush', 'nishu', 'siya', 'priti', 'jinu']
['khush', 'nishu', 'priti']
['khush', 'priti']
['priti']
[1, 2, 3, 4, 5]
length is 5
1
2
3
4
5
['khush', 'keri', 'ketan', 'khushi']
after sorting :
['keri', 'ketan', 'khush', 'khushi']
['khush', 'keri', 'ketan', 'khushi']
after reverse :
['khushi', 'ketan', 'keri', 'khush']
['khush', 'keri', 'ketan', 'khushi']
khushi
keri
maximum and minimum in numbers
[1, 2, 3, 4, 5]
5
1
[1, 2, 3, 4, 5]
5
1
[]

You May Also Like This Article :


Python Lambda

8) Program :


a = 5
b = 2

sum = a+b
print("sum is : "+str(sum))

a = 5
b = 2

sub = a-b
print("substraction is : "+str(sub))

a = 5
b = 2

mul = a*b
print("multiplication is : "+str(mul))

a = 5
b = 2

div = a/b
print("divison is : "+str(div))

a = 5
b = 2

mod = a%b
print("modulo is : "+str(mod))

Output :


sum is : 7
substraction is : 3
multiplication is : 10
divison is : 2.5
modulo is : 1

Python Break

9) Program :


a='khush'
print("without break statement")
for i in a:
    print(i,end='')
print()

print ("with break statement")
for i in a :
    if i=='u' :
        break
    print(i)

for i in range (1,11):
    if i==6:
        break
    print(i)

for i in range (1,11):
    if i==6:
        continue
    print(i)

Output :


without break statement
khush
with break statement
k
h
1
2
3
4
5
1
2
3
4
5
7
8
9
10

Python Class

10) Program :


class Student:   
    def __init__(self, name): 
        print("This is parametrized constructor") 
        self.name = name 
    def show(self): 
        print("Hello",self.name) 
student = Student("Nibkarma") 
student.show()

Output :


This is parametrized constructor
Hello Nibkarma

11) Program :


def func():
    print("def called")
func()

def func(name):
    print("hi "+ name)
func('khush')

def value(a):
    print("a is "+str(a))
value(10)

def func(name):
    print("name is :"+name)
s=input("enter name:")
func(s)

def func(name):
    msg=print("hi "+name)
    return msg;
name=input("enter name :")
func(name)

Output :


def called
hi khush
a is 10
enter name:khush
name is :khush
enter name :khush
hi khush

Python Data-types

12) Program :



x=2
y=3.4
z=False

print(x)
print(y)
print(z)


x = 2
y = 3
sum = x+y
print(sum)

a=int(input("Enter a:"))
b=int(input("Enter b:"))
print("\n")

sum = a+b
sub = a-b
mul = a*b
div = a/b
mod = a%b

print(sum)
print(sub)
print(mul)
print(div)
print(mod)

Output :


2
3.4
False
5
Enter a: 3
Enter b:4


7
-1
12
0.75
3

Simple Python Programs :


1) Program :


Python program to print Hello World.

# This prints Hello World on the output screen
print('Hello World')

Output :


Hello World

2) Program : 


For Getting input in Python by user.

str = input("Enter any string: ")
print(str)

Output :


Enter any string: NibKarma
NibKarma

3) Program : 


Python program to check if a number is positive or negative.

number = int(input("Enter number: "))

# checking the number
if number < 0: print("The entered number is negative.") elif number > 0:
    print("The entered number is positive.")
elif number == 0:
    print("Number is zero.")
else:
    print("The input is not a number")

Output :


Enter Number: 200
The entered number is positive.

4) Program :


Python program to check leap year.

year = int(input("Enter Year: "))

# Leap Year Check
if year % 4 == 0 and year % 100 != 0:
    print(year, "is a Leap Year")
elif year % 100 == 0:
    print(year, "is not a Leap Year")
elif year % 400 ==0:
    print(year, "is a Leap Year")
else:
    print(year, "is not a Leap Year")

Output :


Enter Year: 2016
2016 is a Leap Year

5) Program :


Python program to check whether the input character is an alphabet.

ch = input("Enter a character: ")
if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
    print(ch, "is an Alphabet")
else:
    print(ch, "is not an Alphabet")

Output :


Enter a character : N
N is an alphabet

6) Program :


Python program to check vowel or consonant.

ch = input("Enter a character: ")

if(ch=='A' or ch=='a' or ch=='E' or ch =='e' or ch=='I'
 or ch=='i' or ch=='O' or ch=='o' or ch=='U' or ch=='u'):
    print(ch, "is a Vowel")
else:
    print(ch, "is a Consonant")

Output :


Enter a character : I
I is a Vowel

Things You Should Know About Python Before Learning Python :


Python is an interpreted, high-level, general-purpose programming language. Developed by Guido van Rossum and first released in 1991,

The Reasons  For Why Writing Software Applications in Python


1) Readable and Maintainable Code
2) Multiple Programming Paradigms
3) Compatible with Major Platforms and Systems
4) Robust Standard Library
5) Many Open Source Frameworks and Tools
6) Simplify Complex Software Development
7) Adopt Test Driven Development

The Python Applications :


1) Web and Internet Development
2) Applications of Python Programming in Desktop GUI
3)  Science and Numeric Applications
4) Software Development Application
5) Python Applications in Education
6) Python Applications in Business
7) Database Access
8) Network Programming
9) Games and 3D Graphics
10) Console-based Applications
11) Audio – or Video- based Applications
12) Applications for Images
13) Enterprise Applications
14) 3D CAD Applications
15) Computer Vision
16) Machine Learning
17) Robotics
18) Web Scraping
19) Scripting
20) Artificial Intelligence
21) Data Analysis

You can also learn :


You Also Can Search For Other Python Keywords Like :



Python , Python For Loop  , Python Loops  , Python Tutor  , Python Tutorial  , Python Dictionary  , Python Learning  , For Python List  , Python List  , Python Anaconda  , Python Download  , Python Range  , Python Regex  , Python Else If  , Python If Else  , Python Programming  , Python Snake  , Python Class  , Python Set  , Python In Function  , Python Function  , Python 3  , Python Pandas  , Python Random  , Python Array  , Python Requests  , Python Tuple  , Python Enumerate  , Python Write To File  , Python IDE  , Python Logger

 Python String  , Python While Loop  , Python Map  , Python Install  , Python Read File  , Python Code  , Python Flask  , Python Json  , Python Operator  , Python Or Operator  , Python Zip  , Python Compiler Online  , Python Online Compiler  , Python Online  , Python Replace  , Python Join  , Python Unit Testing  , Python Unittest  , Python Machine Learning  , Python With Machine Learning  , Python Certification  , Why Python For Machine Learning  , Python Interview Questions  , Python gui  , Python Reverse String  , Python Compiler

The Python Regular Expression  , Python Queue  , Python 2.7  , Python Yield  , Python Web Scraping  , Python IDE Online  , Python Django  , Python Scripting  , Python Numpy  , Python Multithreading  , For Python  , Python Or  , Python Generator  , Python For Windows  , Python 3.7  , With Python  , Python Documentation  , Python Version  , Python Beginners  , Python For Beginners  , Python Language  , Python List Functions  , Python Projects  , Python Data Structures  , Python Mysql  , Python Library  , Python And  , Python w3schools  , Python Modules  , Python Hello World  , Python Data Types  , Python 3.6  , Python Interpreter

Python Keyerror  , Python Ord  , Python Meaning  , Python Ordereddict  , Python Xrange  , Pythonanywhere  , Python Range Function  , Python For Data Analysis  , Python With Data sScience  , Python For Data Science  , Python Basics  , Python Interpreter Online  , Python Online interpreter  , Python Cheat Sheet  , Python Cheat Sheet  , Python vs Java  , Python Syntax  , Python Xml Parser  , Python Xml Parsing  , Python Join List  , Python Editor








Python Program With Loops And Conditions !!

Python Program With Loops And Conditions !!



In this article we will discuss about  programs of python with loops and conditions.

  • Python Program For Print The Numbers
  • Python Program To Print All Prime Numbers Of An Interval
  • Python Program For Find The Factorial Of a Number
  • Python Program For Display Number Of The Table
  • Python Program For Print Fibonacci Series
  • Python Program For Sum Of Natural Numbers
  • Python Program For Print Different Patterns

Print The Numbers 


Program :


Output :

Enter a number: 10
0
1
2
3
4
5
6
7
8
9
10

Print Prime Number Of An Interval


Program :


Output :

Enter starting point of the range : 10
Enter ending point of the range : 70
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67


Find The Factorial Of a Number


Program :


Output :

Enter a number: 5
factorial of 5 is 120

Display Table Of The Number 


Program :


Output :

Enter which number's table want to display :  5
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50

Print Fibonacci Series


Program :


Output :

How many terms you want? 10
Fibonacci sequence:
0 , 1, 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 

Sum Of Natural Numbers


Program :


Output :

Enter a number: 50
The sum is 1275

Print The Patterns


Program :

                         

Output :

    * 

   * * 

  * * * 

Program :

                                                      

Output :

#
# # 
# # # 
# # # #

Program :

                                        

Output :

enter the name : Khush
K
K h
K h u
K h u s
K h u s h

In this article we learn different conditions with different loop statements and print patterns. I hope you like it, for more articles keep join us!!

Basic Programs Of All Python Methods


1) Program :


Python program to print Hello World.

# This prints Hello World on the output screen
print('NibKarma')

Output :


Hello NibKarma

List Programs

2) Program :



def string_length(str):
    count = 0
    for char in str:
        count += 1
    return count
print(string_length('NibKarma'))


Output : 8

Python Dictionary

3) Program :


def char_frequency(str):
    dict = {}
    for n in str:
        keys = dict.keys()
        if n in keys:
            dict[n] += 1
        else:
            dict[n] = 1
    return dict
print(char_frequency('NibKarma'))

Output :


{'a': 2, 'N': 1, 'i': 1, 'K': 1, 'r': 1, 'm': 1}

Python Tuple 

4) Program :

tuple=('a','b','c','d','e')
print(tuple)
del tuple[1]
print(tuple)

Output :


('a', 'b', 'c', 'd', 'e')

5) Program :



a = "Hello world"
print(a)
print(a[0])
print(a[1])
print(a[2])

x = "Hello"
y = "Khush"
print(x+y)

s = "Hello Khush"
print(s[0:2])
print(s[2:7])
print(s[4:])

Output :


Hello world
H
e
l
HelloKhush
He
llo K
o Khush

Python Pass

6) Program :


l=[1,2,3,4,5]
for i in l:
    if i==3:
        pass
        print ("Pass execute")
        print("Hello khush")
    print(i)

Output :


1
2
Pass execute
Hello khush
3
4
5

Python List

7) Program :



a1=["khush","jinu","ashu","shwetu"]
print(a1)
a3=['a','b','c']
print(a3)
a5=[1,2,3]
print(a5)
a6=[1,'khush']
print(a6)


a=['a','b','c','d','e']
print(a)
a[2]=3
print(a)
a[1:3]=1,2
print(a)
a[0:]=1,2,3,4,5
print(a)
del a[1]
print(a)

n=["khush","nishu","priti"]
print(n)
n.append("jinu")
print(n)
n.insert(2,"siya")
print(n)

n=["khush","nishu","priti"]
print(n)
n.remove("nishu")
print(n)
n.remove(n[0])
print(n)

n=[1,2,3,4,5]
print(n)
print("length is "+str(len(n)))

n=[1,2,3,4,5]
for i in n:
    print(i)

a=["khush","keri","ketan","khushi"]
print(a)
print("after sorting :")
a.sort()
print(a)

a=["khush","keri","ketan","khushi"]
print(a)
print("after reverse :")
a.reverse()
print(a)

a=["khush","keri","ketan","khushi"]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)

print("maximum and minimum in numbers")

a=[1,2,3,4,5]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)

a=[1,2,3,4,5]
print(a)
n=max(a)
print(n)
n=min(a)
print(n)
a.clear()
print(a)


Output :


['khush', 'jinu', 'ashu', 'shwetu']
['a', 'b', 'c']
[1, 2, 3]
[1, 'khush']
['a', 'b', 'c', 'd', 'e']
['a', 'b', 3, 'd', 'e']
['a', 1, 2, 'd', 'e']
[1, 2, 3, 4, 5]
[1, 3, 4, 5]
['khush', 'nishu', 'priti']
['khush', 'nishu', 'priti', 'jinu']
['khush', 'nishu', 'siya', 'priti', 'jinu']
['khush', 'nishu', 'priti']
['khush', 'priti']
['priti']
[1, 2, 3, 4, 5]
length is 5
1
2
3
4
5
['khush', 'keri', 'ketan', 'khushi']
after sorting :
['keri', 'ketan', 'khush', 'khushi']
['khush', 'keri', 'ketan', 'khushi']
after reverse :
['khushi', 'ketan', 'keri', 'khush']
['khush', 'keri', 'ketan', 'khushi']
khushi
keri
maximum and minimum in numbers
[1, 2, 3, 4, 5]
5
1
[1, 2, 3, 4, 5]
5
1
[]

You May Also Like This Article :


Python Lambda

8) Program :


a = 5
b = 2

sum = a+b
print("sum is : "+str(sum))

a = 5
b = 2

sub = a-b
print("substraction is : "+str(sub))

a = 5
b = 2

mul = a*b
print("multiplication is : "+str(mul))

a = 5
b = 2

div = a/b
print("divison is : "+str(div))

a = 5
b = 2

mod = a%b
print("modulo is : "+str(mod))

Output :


sum is : 7
substraction is : 3
multiplication is : 10
divison is : 2.5
modulo is : 1

Python Break

9) Program :


a='khush'
print("without break statement")
for i in a:
    print(i,end='')
print()

print ("with break statement")
for i in a :
    if i=='u' :
        break
    print(i)

for i in range (1,11):
    if i==6:
        break
    print(i)

for i in range (1,11):
    if i==6:
        continue
    print(i)

Output :


without break statement
khush
with break statement
k
h
1
2
3
4
5
1
2
3
4
5
7
8
9
10

Python Class

10) Program :


class Student:   
    def __init__(self, name): 
        print("This is parametrized constructor") 
        self.name = name 
    def show(self): 
        print("Hello",self.name) 
student = Student("Nibkarma") 
student.show()

Output :


This is parametrized constructor
Hello Nibkarma

11) Program :


def func():
    print("def called")
func()

def func(name):
    print("hi "+ name)
func('khush')

def value(a):
    print("a is "+str(a))
value(10)

def func(name):
    print("name is :"+name)
s=input("enter name:")
func(s)

def func(name):
    msg=print("hi "+name)
    return msg;
name=input("enter name :")
func(name)

Output :


def called
hi khush
a is 10
enter name:khush
name is :khush
enter name :khush
hi khush

Python Data-types

12) Program :



x=2
y=3.4
z=False

print(x)
print(y)
print(z)


x = 2
y = 3
sum = x+y
print(sum)

a=int(input("Enter a:"))
b=int(input("Enter b:"))
print("\n")

sum = a+b
sub = a-b
mul = a*b
div = a/b
mod = a%b

print(sum)
print(sub)
print(mul)
print(div)
print(mod)

Output :


2
3.4
False
5
Enter a: 3
Enter b:4


7
-1
12
0.75
3

Simple Python Programs :


1) Program :


Python program to print Hello World.

# This prints Hello World on the output screen
print('Hello World')

Output :


Hello World

2) Program : 


For Getting input in Python by user.

str = input("Enter any string: ")
print(str)

Output :


Enter any string: NibKarma
NibKarma

3) Program : 


Python program to check if a number is positive or negative.

number = int(input("Enter number: "))

# checking the number
if number < 0: print("The entered number is negative.") elif number > 0:
    print("The entered number is positive.")
elif number == 0:
    print("Number is zero.")
else:
    print("The input is not a number")

Output :


Enter Number: 200
The entered number is positive.

4) Program :


Python program to check leap year.

year = int(input("Enter Year: "))

# Leap Year Check
if year % 4 == 0 and year % 100 != 0:
    print(year, "is a Leap Year")
elif year % 100 == 0:
    print(year, "is not a Leap Year")
elif year % 400 ==0:
    print(year, "is a Leap Year")
else:
    print(year, "is not a Leap Year")

Output :


Enter Year: 2016
2016 is a Leap Year

5) Program :


Python program to check whether the input character is an alphabet.

ch = input("Enter a character: ")
if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
    print(ch, "is an Alphabet")
else:
    print(ch, "is not an Alphabet")

Output :


Enter a character : N
N is an alphabet

6) Program :


Python program to check vowel or consonant.

ch = input("Enter a character: ")

if(ch=='A' or ch=='a' or ch=='E' or ch =='e' or ch=='I'
 or ch=='i' or ch=='O' or ch=='o' or ch=='U' or ch=='u'):
    print(ch, "is a Vowel")
else:
    print(ch, "is a Consonant")

Output :


Enter a character : I
I is a Vowel

Things You Should Know About Python Before Learning Python :


Python is an interpreted, high-level, general-purpose programming language. Developed by Guido van Rossum and first released in 1991,

The Reasons  For Why Writing Software Applications in Python


1) Readable and Maintainable Code
2) Multiple Programming Paradigms
3) Compatible with Major Platforms and Systems
4) Robust Standard Library
5) Many Open Source Frameworks and Tools
6) Simplify Complex Software Development
7) Adopt Test Driven Development

The Python Applications :


1) Web and Internet Development
2) Applications of Python Programming in Desktop GUI
3)  Science and Numeric Applications
4) Software Development Application
5) Python Applications in Education
6) Python Applications in Business
7) Database Access
8) Network Programming
9) Games and 3D Graphics
10) Console-based Applications
11) Audio – or Video- based Applications
12) Applications for Images
13) Enterprise Applications
14) 3D CAD Applications
15) Computer Vision
16) Machine Learning
17) Robotics
18) Web Scraping
19) Scripting
20) Artificial Intelligence
21) Data Analysis


You can also learn :

You Also Can Search For Other Python Keywords Like :



Python , Python For Loop  , Python Loops  , Python Tutor  , Python Tutorial  , Python Dictionary  , Python Learning  , For Python List  , Python List  , Python Anaconda  , Python Download  , Python Range  , Python Regex  , Python Else If  , Python If Else  , Python Programming  , Python Snake  , Python Class  , Python Set  , Python In Function  , Python Function  , Python 3  , Python Pandas  , Python Random  , Python Array  , Python Requests  , Python Tuple  , Python Enumerate  , Python Write To File  , Python IDE  , Python Logger

 Python String  , Python While Loop  , Python Map  , Python Install  , Python Read File  , Python Code  , Python Flask  , Python Json  , Python Operator  , Python Or Operator  , Python Zip  , Python Compiler Online  , Python Online Compiler  , Python Online  , Python Replace  , Python Join  , Python Unit Testing  , Python Unittest  , Python Machine Learning  , Python With Machine Learning  , Python Certification  , Why Python For Machine Learning  , Python Interview Questions  , Python gui  , Python Reverse String  , Python Compiler

The Python Regular Expression  , Python Queue  , Python 2.7  , Python Yield  , Python Web Scraping  , Python IDE Online  , Python Django  , Python Scripting  , Python Numpy  , Python Multithreading  , For Python  , Python Or  , Python Generator  , Python For Windows  , Python 3.7  , With Python  , Python Documentation  , Python Version  , Python Beginners  , Python For Beginners  , Python Language  , Python List Functions  , Python Projects  , Python Data Structures  , Python Mysql  , Python Library  , Python And  , Python w3schools  , Python Modules  , Python Hello World  , Python Data Types  , Python 3.6  , Python Interpreter

Python Keyerror  , Python Ord  , Python Meaning  , Python Ordereddict  , Python Xrange  , Pythonanywhere  , Python Range Function  , Python For Data Analysis  , Python With Data sScience  , Python For Data Science  , Python Basics  , Python Interpreter Online  , Python Online interpreter  , Python Cheat Sheet  , Python Cheat Sheet  , Python vs Java  , Python Syntax  , Python Xml Parser  , Python Xml Parsing  , Python Join List  , Python Editor