Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: Program to find Mode of a list
Post: RE: Program to find Mode of a list
(Sep-11-2023, 04:13 PM)deanhystad Wrote: If you want to convert values to int then compute the mode fine. If you pass strings and convert the result to an int, fine. Mode doesn't care. If you wan... |
|
PythonBoy |
General Coding Help |
6 |
1,218 |
Sep-12-2023, 09:31 AM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-11-2023, 07:24 PM)deanhystad Wrote: Sitting at the keyboard is not the right way to start programming. First you solve the problem, then you code the solution.
Is 1234521 a palindrome
Output:... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-12-2023, 09:27 AM |
|
|
Thread: Program to find Mode of a list
Post: RE: Program to find Mode of a list
(Sep-11-2023, 03:30 PM)deanhystad Wrote: Why are you converting the values to int? You aren't doing any arithmetic.
A way to do this without using any imports.
def mode(items):
counts = {}
... |
|
PythonBoy |
General Coding Help |
6 |
1,218 |
Sep-11-2023, 03:55 PM |
|
|
Thread: Program to find Mode of a list
Post: RE: Program to find Mode of a list
(Sep-11-2023, 02:43 PM)snippsat Wrote: To fix some stuff and make it look better.
Try not to use capital letters for variables.
On line 2 make a list,so can use that list for rest of stuff to,no ne... |
|
PythonBoy |
General Coding Help |
6 |
1,218 |
Sep-11-2023, 03:06 PM |
|
|
Thread: Error is finding mean of a list
Post: RE: Error is finding mean of a list
(Sep-11-2023, 04:57 AM)perfringo Wrote: Length of the Data1 is zero at the time of assignment. If you move this row after the for loop you solve the ZeroDivisionError.
However, Sum have the same pr... |
|
PythonBoy |
General Coding Help |
4 |
987 |
Sep-11-2023, 02:38 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-11-2023, 12:21 PM)jefsummers Wrote: You mentioned that this is supposed to use loops. The slicing technique is better and faster, but must consider what the instructor is wanting to teach you. ... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-11-2023, 02:36 PM |
|
|
Thread: Program to find Mode of a list
Post: Program to find Mode of a list
I am currently making a program to find the Mode of a list by count() function.
Input =input("Please enter the data: ")
Data = Input.split(",")
#Storing all integers in this empty list
Data1 = []
#C... |
|
PythonBoy |
General Coding Help |
6 |
1,218 |
Sep-11-2023, 01:58 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-10-2023, 11:13 PM)Skaperen Wrote: (Sep-07-2023, 01:43 PM)PythonBoy Wrote: I am interested in this method also. Could you please explain why did we write y = x[::-1]?which aspect of this are y... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-11-2023, 03:03 AM |
|
|
Thread: Program to find Mean, Median and Mode
Post: RE: Program to find Mean, Median and Mode
(Sep-10-2023, 01:41 PM)deanhystad Wrote: Don't write multiple posts for the same topic
I am sorry, I posted it mistakenly, I couldn't figure how to delete it. Please help me figuring out on how to d... |
|
PythonBoy |
General Coding Help |
4 |
112 |
Sep-10-2023, 04:42 PM |
|
|
Thread: Error is finding mean of a list
Post: RE: Error is finding mean of a list
(Sep-10-2023, 08:53 AM)perfringo Wrote: Python interactive interpreter is your best friend.
>>> a = []
>>> len(a)
0
>>> # source of ZeroDi... |
|
PythonBoy |
General Coding Help |
4 |
987 |
Sep-10-2023, 11:33 AM |
|
|
Thread: Error is finding mean of a list
Post: Error is finding mean of a list
So I was making a program to find the mean of a list entered by the user
My code:
Input =input("Please enter the data: ")
Data = Input.split(",")
Data1 = []
Length = len(Data1)
Sum = sum(Data1)
for x... |
|
PythonBoy |
General Coding Help |
4 |
987 |
Sep-10-2023, 07:26 AM |
|
|
Thread: Help needed for a program using loops
Post: RE: Help needed for a program using loops
(Sep-10-2023, 06:36 AM)purush167 Wrote: try this code
num = int(input("Please enter number of times: "))
for numb1 in range(1, num):
print ("X" * numb1)
Yes, this works too.
But here I see t... |
|
PythonBoy |
Homework |
5 |
1,459 |
Sep-10-2023, 06:51 AM |
|
|
Thread: Program to find Mean, Median and Mode
Post: RE: Program to find Mean, Median and Mode
(Sep-10-2023, 06:22 AM)purush167 Wrote: remove 3 rd line. you are assigning blank data.
Ohh ok, I understood now.
Thanks for helping me! **smile** |
|
PythonBoy |
General Coding Help |
4 |
112 |
Sep-10-2023, 06:49 AM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-07-2023, 02:47 PM)DPaul Wrote: (Sep-07-2023, 01:43 PM)PythonBoy Wrote: I am interested in this method also. Could you please explain why did we write y = x[::-1]?
Look here:
https://www.guru9... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 03:26 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-07-2023, 01:42 PM)PythonBoy Wrote: (Sep-07-2023, 01:33 PM)DPaul Wrote: Hi, No loops allowed ? then try:
x = '1234321'
y = x[::-1]
Is y == x ?
Paul
Although this is not the way my teacher wa... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:43 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-07-2023, 01:38 PM)snippsat Wrote: (Sep-07-2023, 01:23 PM)PythonBoy Wrote: So are you telling me that if I download Python 3.11(newest version) then this program will work?, because I think in... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:43 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-07-2023, 01:33 PM)DPaul Wrote: Hi, No loops allowed ? then try:
x = '1234321'
y = x[::-1]
Is y == x ?
Paul
Although this is not the want, my teacher wants me to do it,
I am interested in thi... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:42 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
(Sep-07-2023, 01:33 PM)DPaul Wrote: Hi, No loops allowed ? then try:
x = '1234321'
y = x[::-1]
Is y == x ?
Paul
Thanks for the reply but the homework is to do it using loops |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:38 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: RE: Program to check whether a number is palindrom...
Thanks very much for the help!
So are you telling me that if I download Python 3.11(newest version) then this program will work?, because I think in Python 2.7 value of len() cannot be an integer and... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:23 PM |
|
|
Thread: Program to check whether a number is palindrome or not
Post: Program to check whether a number is palindrome or...
A palindrome number is a number which if written backwards also, the number will look the same
Eg: 112211, 121, 898
I have a homework to write a program to check if a number is palindrome or not usin... |
|
PythonBoy |
Homework |
18 |
2,924 |
Sep-07-2023, 01:13 PM |