User input and lists

I’m creating a book recommendation program and after the user gets their book suggestions they can choose how many books they would like the price of. I want the user to choose how many books they would like to see the prices for, and also randomize them. But I’m just wondering about the execution of how to do this, as I’m not very skilled in coding. Btw the prices for the books are all arranged in a list for each genre. Someone pls help!

1 Like

The if statement below was initially intended to print all of the book prices from the list but I’m trying to do it differently.

A quick look its good. A few suggestions are to use .lower() (I think that’s what it is in Python) incase I type something like YES.

1 Like

While I understand what you are trying to do, this is not a small thing to do and it would need recommender systems. You can try to find a tutorials and ignore the maths and just learn the mechanics.
Even if learning the math or at least the basics would be a better approach.

This said, the basic idea is to use data in order to find the most close people in terms of book taste in order to suggest something.

Some examples

The book recommendations are based off of what genre the user picks and also their age, and the list that caters to this specific info is printed.

But thank you actually! I might use these to make a more efficient program.

I saw your code in another thread, still have a look at the links I sent … if you manage to understand them, a new world will open up and will be a lot of fun and more. As those are the real recommender systems. And the coding is not too hard … at least the pandas examples I shared.

Well first if you don’t nee to convert the value input() returns to a string as it is already a string. I’m also not sure why you put a */star in your print statement.

I can’t really tell exactly what you want it to do, but if you are trying to generate random numbers you can do it like this:

import random

random_int = random.randint(1, 20) # random int between 1-20

Or if you are trying to randomize the contents of a list you can shuffle them

import random

mylist = [1, 2, 3, 4, 5]

random.shuffle(mylist) # shuffles the list

With random is always better to use seed also or it is not truly random

import random
from datetime import datetime


I disagree, there is no such thing as a true random, and random.randint() and other functions are functionally just as random as using a timestamp for a seed, because I’m pretty sure that’s exactly what they are doing. In computer science there is no real true random, it’s all pseudo random.


Exactly, to further emphasize, try writing a program that polls x random numbers and plots it on a histogram, IIRC the heights will be tallest in the middle and thin out the closer they are to the edges.

1 Like

Yep, the only true random generators use things like the weather.
It’s actually an extremely interesting topic.

1 Like

You can use atomic clocks for randomness. However for all practical purposes using as seed Epoch time is a good approximation.

good explanation :smiley: the only true random is from nature

1 Like

That is also debatable. As There are branches of Quantum Physics like super-determinism that claim that there is no randomness and we believe otherwise only because we are unable to calculate with enough precision.
No free will!

1 Like

dang O_O yeah I saw once that in quantum physics, because of how electrons function it’s possible to “teleport” electrons because when jumping to energy levels, one cannot exist in between so once it reaches a certain amount of energy (kinda like latent heat ig) it just “teleports” and I also saw that electrons become “locked” only when observed, otherwise it’s just a wave of probability!

1 Like

True, there is no such thing as a true random. What is “random” to us is just something we can’t predict, which is why I don’t like using a time stamp as a seed for randomation as time stamps can be predicted.

You are probably confusing electrons jumping bands with quantum entanglement used in quantum networks for instantaneous transmission of data like cryptographic keys. Something my new company might or might not be involved as well.
Oh well, i should stop or i kill the fantasy of young minds :slight_smile:

1 Like

:face_holding_back_tears: I have no idea what your talking about lol I just watched a documentary on quantum physics and thought it was cool