Python Answers

Questions answered by Experts: 5 288

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

If you are trying to print a string, what happens if you leave out one of the quotation marks or both and why?




You can use a minus sign to make a negative number like -2. What happens for each of the following and why?




>>> 2++2





>>> 2--2





>>> 2+-2





>>> 2-+2





In math notation, leading zeros are OK, as in 02. What happens if you try this in Python and why?




What happens if you have two values with no operator and a space in between them and why?

Write a Python program that asks the user to enter an integer (X), then:


Determines if X is prime or not

If X is not prime, compute and print the factors of that integer X

Evaluate and print the equation Y=8X²+ 1, for X values from -5 to 5 using the range function and for loop


Square to the Next Level


by CodeChum Admin



We've already tried printing out the values of an array in reversed order, right? Today, we shall compute for the squares of all the numbers.





There's already a predefined array/list containing 100 integer values. Loop through each values, compute their squares, and display them.



Output



Multiple lines containing an integer.



4


9


25


10000


49


9


25


9


1


16


.


.


.


Only the Even Ones

by CodeChum Admin

I have a list of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the list.

Can you do that for me?


Input

A line containing integers separated by a space.

33·54·32·11·8

Output

Multiple lines containing an integer.

2
54
32
8

 Listing 101

by CodeChum Admin

I want you to make a array/list of numbers for me. All you have to do is make a program that will let me input any random integer in one line. Afterwards, it will then print out all the numbers I've inputted, on separate lines.

Care to do that for me?


Input

A line containing integers separated by a space.

1·64·32·2·11

Output

Multiple lines containing an integer.

1
64
32
2
11




Write a user-define function, called checkNumber(x), that takes as an input an integer

number (read in the main function using input) and prints out positive, negative, or

zero according to whether the number is positive, negative, or zero.


Programming languages like Python are formal languages with strict syntax rules. But those rules can change over time with newer versions of the programming language. Your textbook covers Python 3, but you may only have access to Python 2.

Download and install a working Python environment, preferably Python 3, or get an account with PythonAnywhere. Refer to the Software Requirements/Installation section of the course syllabus for details.

Type the statements below into your Python interpreter. For each statement, copy the output into your Discussion Assignment and explain the output. Compare it with any similar examples in the textbook, and describe what it means about your version of Python.

>>> print 'Hello, World!'

>>> 1/2

>>> type(1/2)

>>> print(01)

>>> 1/(2/3)


you are given a positive integer n. your task is to find the number of positive integers k<=n such that k is not divisible by any of the following numbers 2,3,4,5,6,7,8,9,10.


A pythagorean triplet is a set of three integers a, b and c such that a**2+b**2=c**2.in the given limit L, find the number of pythagorean triplets R that can be formed (such that a<b<c).


given an integer N, write a program that prints the count of the total numbers of digits between 1 and N.


LATEST TUTORIALS
APPROVED BY CLIENTS