Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 13, 2022 06:12 pm GMT

Python 101:Ultimate Guide To Python

Introduction

If you can learn something new everyday, you can teach something new everyday. -Martha Stewart

What Exactly is python?

Developed in 1991 by Guido Van Rossum, python is an interpreted high level programming language.
I know what you're thinking, why would I learn this when there are so many other languages out there? Well, here are a few reasons why you should start learning it now:

  • It is simple and easy to learn syntax
  • It has automatic garbage collection
  • No more semicolons!
  • Huge amount of libraries
  • Is interpreted

To learn more about python, we will do a fun project :)

What Disney princess would you be?

Have you ever wondered what disney princess you would be? Let's find out.
After creating a new file on your preferred text editor, proceed to write this code:

  • prompt user to enter name and introduce them to the program.
    name= input("What is your name?
    ")
    print("Hello "+name+ " Do you ever wonder what disney character you would be? FIND OUT TODAY!")

  • main question for the user
    # questions to help user identify traits
    trait = input("What is your favorite color? pink,blue,yellow or green
    ").lower

  • Sequence of if statements to determine the best character

if trait =="pink":    ans=input("Do you like adventure? y or n: 
").lower if ans=="y": print("Hello Rapunzel") else: print("hello Sleeping Beauty")if trait == "yellow": ans2= input("Would you consider yourself brave? y or n:
").lower if ans2=="y": ans3= input("Would you die for anyone? y or n:
").lower if ans3=="y": print("hello Moana")if trait=="blue": ans4=input("Would you consider yourself confident? y or n:
").lower ans6=input("Would you consider yourself hardworking? y or n:
").lower ans7=input("would you consider yourself a leader? y or n:
").lower if ans7=="yes": print("Hello Elsa") elif ans6=="y": print("Hello Snow White") elif ans4=="y": print("Hello Snow White")if trait =="green": ans8=input("Would you consider yourself a princess? y or n:
").lower if ans8=="n": print("Hello Tiana") else: ans9=input("Would you consider yourself a girly girl? y or n:
").lower if ans9=="n": print("Hello Mulan") else: ans10=input("Do you have a great singing voice? y or n:
") if ans10=="y": print("Hello Ariel") else: print("Hello Merida")
  • The full code will look like this:
name= input("What is your name? 
")print("Hello "+name+ " Do you ever wonder what disney character you would be? fIND OUT TODAY!")# questions to help user identify traitstrait = input("What is your favorite color? pink,blue,yellow or green
").lowerif trait =="pink": ans=input("Do you like adventure? y or n:
").lower if ans=="y": print("Hello Rapunzel") else: print("hello Sleeping Beauty")if trait == "yellow": ans2= input("Would you consider yourself brave? y or n:
").lower if ans2=="y": ans3= input("Would you die for anyone? y or n:
").lower if ans3=="y": print("hello Moana")if trait=="blue": ans4=input("Would you consider yourself confident? y or n:
").lower ans6=input("Would you consider yourself hardworking? y or n:
").lower ans7=input("would you consider yourself a leader? y or n:
").lower if ans7=="yes": print("Hello Elsa") elif ans6=="y": print("Hello Snow White") elif ans4=="y": print("Hello Snow White")if trait =="green": ans8=input("Would you consider yourself a princess? y or n:
").lower if ans8=="n": print("Hello Tiana") else: ans9=input("Would you consider yourself a girly girl? y or n:
").lower if ans9=="n": print("Hello Mulan") else: ans10=input("Do you have a great singing voice? y or n:
") if ans10=="y": print("Hello Ariel") else: print("Hello Merida")

Original Link: https://dev.to/changach/python-101ultimate-guide-to-python-4jp4

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To