milon

joined 2 years ago
[–] milon@lemm.ee 1 points 11 months ago (1 children)

The idiom allowed it to pass the checker's tests! Thanks for your help!

[–] milon@lemm.ee 2 points 11 months ago

That passed the test! Thank you!

[–] milon@lemm.ee 1 points 11 months ago* (last edited 11 months ago) (9 children)

It's for CS50P which uses a customized VS Code. It has an automated code checker which I ran when I was done.

outputs "Just right!" when guess is correct

timed out while waiting for program to exit

[–] milon@lemm.ee 1 points 11 months ago (5 children)

Was using tabs but I went through it to make sure and seemed to be ok.

25
submitted 11 months ago* (last edited 11 months ago) by milon@lemm.ee to c/python@programming.dev
 

There is an issue with the program when the user correctly guesses the number. The program should end when the break statement executes in the while loop found in main(), but instead it times out.

import random


def main():
    level = get_level()
    number = generate_random_number(level)

    while True:
        guess = get_guess()

        if check_guess(number, guess) == False:
            continue
        else:
            break


def get_level():
    while True:
        level = input("Level: ")

        try:
            int(level)
        except ValueError:
            continue
        if int(level) <= 0:
            continue
        else:
            return int(level)

def generate_random_number(level):
    number = random.randint(1, level)

    return number

def get_guess():
    while True:
        guess = input("Guess: ")

        try:
            int(guess)
        except ValueError:
            continue
        if int(guess) <= 0:
            continue
        else:
            return int(guess)

def check_guess(number, guess):
    if guess > number:
        print("Too large!")

        return False
    if guess < number:
        print("Too small!")

        return False
    if guess == number:
        print("Just right!")

        return True


main()
[–] milon@lemm.ee 2 points 11 months ago

Yeah I think I will follow the same approach. 3rd parties are a bit risky.

[–] milon@lemm.ee 1 points 11 months ago (2 children)

Thanks for the additional info. Maybe I will opt for the developer version instead in that case.

[–] milon@lemm.ee 1 points 11 months ago

Yup no issues here

[–] milon@lemm.ee 2 points 11 months ago

I see now. So it's possible for someone to run into multiple issues which can make updating a hassle.

[–] milon@lemm.ee 4 points 11 months ago
[–] milon@lemm.ee 2 points 11 months ago (4 children)
[–] milon@lemm.ee 2 points 11 months ago (2 children)

Yes, I did. I was warned about doing so before but now I understand 😆

[–] milon@lemm.ee 2 points 11 months ago (6 children)

Also, as I reinstall a flathub version of LibreOffice, should I choose the Fedora repo or Flathub repo?

20
submitted 11 months ago* (last edited 11 months ago) by milon@lemm.ee to c/linux@lemmy.ml
 

I am trying to update from Silverblue 41 to 42 (fully updated) but run into issues when attempting to update from both the software app and from CLI.

The problem using the software app is the same as what is described by this other user, who is using Fedora Workstation not Silverblue like I am:

https://discussion.fedoraproject.org/t/update-to-fedora-42-fails-in-gnome-software/148885

When I click the download button, it looks like it's downloading multiple files since the progress bar goes from 0 to 100 several times, and then it gets up to 95% then suddenly returns to the download button. This happens in about 30 seconds.

Using the CLI method, I run the following command:

rpm-ostree rebase fedora:fedora/42/x86_64/silverblue

and get the following errors:

 Problem: conflicting requests
  - package dnf5-plugin-automatic-5.2.12.0-2.fc42.x86_64 from updates requires libcurl-full(x86-64), but none of the providers can be installed
  - package dnf5-plugin-automatic-5.2.12.0-1.fc42.x86_64 from fedora requires libcurl-full(x86-64), but none of the providers can be installed
  - package dnf5-plugin-automatic-5.2.12.0-2.fc42.x86_64 from updates-archive requires libcurl-full(x86-64), but none of the providers can be installed
  - package libcurl-minimal-8.11.1-4.fc42.x86_64 from @System conflicts with libcurl(x86-64) provided by libcurl-8.11.1-4.fc42.x86_64 from fedora

SOLUTION: Uninstalled layered packages in dnf-automatic, libreoffice, and rpmfusion and then restarted. Rebase command successfully completed thereafter.

3
submitted 1 year ago* (last edited 11 months ago) by milon@lemm.ee to c/fedora@lemmy.ml
 

.

 

if coin == 25 | 10 | 5:

If I replace the '|' with 'or' the code runs just fine. I'm not sure why I can't use '|' in the same statement.

Doing the following doesn't work either:

if coin == 25 | coin == 10 | coin == 5:

I know bitwise operators can only be used with integers, but other then that is there another difference from logical operators?

 
 # Ask user to enter an expression and display output
def main():
    expression = input("Expression: ")

    print(calculate(splitter(expression)))


# Split expression into components and assign to variables as float values
def splitter(expression):
    x, y, z = expression.split()

    return x, y, z

# Calculate expression result
def calculate(x, y, z):
    x, z = float(x), float(z)

    if y == "+":
        return str(round((x + z), 1))
    elif y == "-":
        return str(round((x - z), 1))
    elif y == "*":
        return str(round((x * z), 1))
    else:
        return str(round((x / z), 1))



main()

I am getting traceback errors for any expression (1 + 1) I enter.

view more: next ›