answersLogoWhite

0

Python Programming

Python was first released in 1991, it is an high-level programming language. It was created by Python Software Foundation. The language is influenced by a number of programming language such as C, Lisp, Perl, Java and others.

155 Questions

Why is a bubble sort often presented first when learning sorting methods?

Bubble sort is often taught first because it's a really simple sort, and quite easy to comprehend. Specifically in Python you should never write your own sort, but use the sorted() builtin function.

What book should you use for learning Python 2.7?

I have done a little coding but I am a complete beginner to programming in Python. Can anybody recommend a book to teach me the basics?

Thanks

How do you draw HELLO WORLD in python?

There are a couple of ways:
1. Use turtle. It is a module that can be imported.

2. The print function

3. Use tkinter. It is a module in python that you can import.

Is python is pure platform independent?

Yes! The Python standard library takes considerations to what platform you are on, especially in the OS module. Now, if you are opening files (or walking the filesystem, etc) you need to take care that your filepaths are system independent, if you want that.

What is the Python script for nth prime number?

As people have been trying to find a script of some sort using the most powerful computers in the world for 60 years to no result, so no one can assist you in this question yet...

Which fields one can choose for career after Python certification?

GIS Analyst, Data Scientist, Python Developer, Product Manager, Data Analyst, Python Trainer are some of the field that you can choose as a career. There are many good institutes that provide deep learning of programming languages. Prognoz Technologies pvt ltd is one of those companies in Mumbai, India that provides python training with internship programs.

Visit: Prognoz Technologies pvt ltd

How do i make a slither.io bot?

Check out this web site: h t t p s : / / s l i t h e r e . c o m / s l i t h e r - i o - b o t s /

How do you import math functions in python?

At the top of your program:

import math

or

from math import *

The second one imports all math functions, like fact() for factorial.

How do you write a python program to print even numbers from 1 to 100 using while loop?

This can be easily done using the modulo operation (represented by the '%' symbol). This operation gives the remainder of the division of the two numbers used in it.

e.g. 4 % 2 = 0, 5 % 2 = 1, 10 % 3 = 1, 10 % 2 = 0

In a modulo operation, any even number divided by 2 will always have a remainder of 0. This can be done in Python for a number range like so:

current_number = 1 # variable to store the current number being checked

while current_number <= 100: # loop to go through the range of numbers up until 10

if current_number % 2 == 0: # check if the current number has a remainder of 0

print(current_number) # if it does, then print it out

current_number += 1 # move to the next number

This will print out all the even numbers up until 100, each on a separate line.

Where can one find tutorials on how to create Python time programs?

Python is a high level interactive, object-oriented programming language. If one requires a tutorial to create Python time programs there is a full tutorial available on the Tutorials Point website.

How you can write python code to disply the prime factors of 60?

def factors(n):

return [(x, sum([1 for y in range(1,int(ceil(log(n, x)))+1) if n%x**y == 0])) for x in range(2,int(n/2)) if all([x%q!=0 for q in range(2,int(x/2)+1)]) and n % x == 0]

This will give you a list of factors with their exponents:

print(factors(60))

# prints: [(2, 2), (3, 1), (5, 1)]

How do you write a source code for regula-falsi method using python?

Clothing has always been a thing that has been given a great ioctrmanpe by human beings. It displays the attitude that the people exhibit. Lots of brands have been existent in the clothing industry and a famous one among them is the Ed hardy clothing brand.The brand got its name from the famous American tattoo artist Ed Hardy. He was a very famous tattoo artist and has published many books on tattooing techniques. But his tattooing turned into a brand by the efforts of a company called Christian Audiger. This company was a very famous and very powerful company in the field of clothing. They felt that it would be appropriate to create a brand called Ed hardy and use Hardy's art as the main selling point for the brand. This venture had turned out to be a very successful one and Ed hardy clothing is one of the most famous brands in the clothing industry.The brand became very famous because it was worn by many famous celebrities like Madonna, Britney spears and also Sylvester Stallone. The brand has clothes for men, women, and kids. They have also diversified their business by having a lot of accessories to support their clothing business. for men they have a variety of products such as active wear, denim, outwear, swim trucks, sweaters, t-shirts, tops etc. the accessories include things such as belts, caps, scarves, shoes, socks, jeweler, sunglasses, ties and even wallets.The art works is a unique combination of American and Japanese cultures. The unique selling proposition of the brand is the way in which the company has used the art works of Ed hardy.

How do you draw a star in python?

import turtle

from random import*

def star(a,b,c,d):

x=5

y=0

turtle.color(a)

turtle.begin_fill()

turtle.penup()

turtle.goto(c,d)

turtle.pendown()

while x>0:

turtle.forward(b)

turtle.right(144)

turtle.forward(b)

x-=1

turtle.end_fill()

star('red',100,0,0)

def length():

randvar=randrange(5,71)

def x():

randvar=randrange(-280,281)

def y():

randvar=randrange(-200,201)

def night_sky():

z=int(input('How many stars do you want?'))

a=random_color

b=length

c=x

d=y

while z>0:

star(a,b,c,d)

z-=1

How do you write a horoscope program on python?

Hi gys, are you looking to write a program to know the sign depends on the birth date or horoscope on python? write down following codes on python, those will make a nice program.

#This program will get the horoscope sign.

def getSign():

name = raw_input ("Enter Your Name: ")

month = raw_input("Enter Birth Month: ")

day = int(raw_input("Enter Birth Day of Month: "))

if month "y":

main()

letter = raw_input("Go again? (y/n): ")

How do you make a program in python using do while loop to display the multiplication table of number from one to ten?

a = 0

while a < 10 :

a += 1

print (a)

Write the above simple script in a text editor (I use nano). Save as loop.py in home folder. To run, open a terminal and at the prompt, write: python loop.py

Result:

rodney@downstairs:~$ python loop.py

1

2

3

4

5

6

7

8

9

10

How is a relationship created in SQL Server?

In the table design view, right click the column name of the entity you want to create a relationship with and then select "Relationships" which opens the Properties window with the Relationships tab selected. Click on "New" and then verify the "Primary key table" and "Foreign key table". Select the primary key from the grid below the "Primary key table" name (left side of grid) and then select the column name you right-clicked on earlier from the grid below the " Foreign key table" name (right side of grid). Selecting each one in turn sets the two into the desired relationship.

How do you calculate factors of a number using python programming language?

An easy way to calculate all the factors of whole numbers is to iterate from 1 to that number and check if the remainder is zero using the "%" operation.

def getFactors(num):

"""Return the factors of a whole number"""

factors = []

for i in range(1,num+1):

if num%i == 0:

factors.append(i)

return factors

Factoring negative numbers and zero simply requires a few more tweaks to the code.

Which of the following function convert an object to a string in python?

By using "str()".

Example:

number = 2

yourNumber = print("Your number is %s!") % (str(number))

Python function that lists prime numbers?

If you just want a hint:

One way to check whether a number is prime is by dividing it by any number between 2 and the square root of your number. If the number divides by any of these, it is not prime.

If you want the code:

import math for num in range(1,101): if all(num%i!=0 for i in range(2,int(math.sqrt(num))+1)): print num

Using Python write an algorithm that takes a string as input and determines whether or not it is a palindrome?

def isPalindrome(s): return s == s[::-1]

then just call the function with a string like

isPalindrome('poop')

How do you add list in python?

>>> list1 = [3,5]

>>> list2 = ['foo','bar']

>>> ans = list1

>>> print ans

[3, 5]

>>> for var in list2:

ans.append(var)

>>> print ans

[3, 5, 'foo', 'bar']

this might not be the most efficient way to add lists together but it works.

ans.append(var) means to add the variable 'var' to the end of list 'ans'. the reason I put this in a for loop is if I just said ans.append(list2), the answer would be [3,5,['foo,bar']].