Go to advanced search

by rpiboy
Mon Nov 16, 2020 12:07 am
Forum: C/C++
Topic: Which programming language to learn first
Replies: 34
Views: 1263

Which programming language to learn first

Should I learn C first and then learn C++?
by rpiboy
Wed Nov 11, 2020 3:00 pm
Forum: Beginners
Topic: How to point to a executable
Replies: 6
Views: 264

Re: How to point to a executable

It would help if you could post some terminal output - that is, something like: $ type -a wget;echo $PATH ... $ wget --version | head -2 ... $ /usr/bin/wget --version | head -2 ... $ /usr/local/bin/wget --version | head -2 ... Also, this could be down to not having rebooted or re-started the shell ...
by rpiboy
Wed Nov 11, 2020 2:27 am
Forum: Beginners
Topic: How to point to a executable
Replies: 6
Views: 264

Re: How to point to a executable

Weezy
by rpiboy
Tue Nov 10, 2020 9:49 pm
Forum: Beginners
Topic: How to point to a executable
Replies: 6
Views: 264

How to point to a executable

I have an older version of wget installed which is 1.16. I also installed the new version 1.20. When I run wget it still points to /usr/bin/wget which is version 1.16 instead of /usr/local/bin/wget which is version 1.20
by rpiboy
Thu Jul 02, 2020 10:20 pm
Forum: Python
Topic: Help with data frame function
Replies: 1
Views: 172

Help with data frame function

Write a function that filters the dataset for questions that contains all of the words in a list of words. For example, when the list ["King", "England"] was passed to our function, the function returned a DataFrame of 152 rows. Every row had the strings "King" and "England" somewhere in its " Ques...
by rpiboy
Fri Jun 26, 2020 9:23 pm
Forum: Python
Topic: Pandas column & row help
Replies: 0
Views: 109

Pandas column & row help

https://imgur.com/YEJvWTQ First code: orders['shoe_source'] = orders.shoe_material.apply(lambda x: \ 'animal' if x == 'leather'else 'vegan') Second code: orders['salutation'] = orders.apply(lambda row: \ 'Dear Mr. ' + row['last_name'] if row['gender'] == 'male' else 'Dear Ms. ' + row['last_name'], ...
by rpiboy
Fri Jun 19, 2020 8:47 pm
Forum: Python
Topic: Percentage with Numpy
Replies: 11
Views: 1031

Re: Percentage with Numpy

pidd wrote:
Fri Jun 19, 2020 8:05 pm
Because 96% of them are above 60? (74/77)
That's the answer thanks :D
74/77. It removes the three values that are false and divide by the total numbers in the array.
by rpiboy
Fri Jun 19, 2020 8:26 pm
Forum: Python
Topic: Percentage with Numpy
Replies: 11
Views: 1031

Re: Percentage with Numpy

pidd wrote:
Fri Jun 19, 2020 8:05 pm
Because 96% of them are above 60? (74/77)
So why do I have to use np.mean to calculate the percentage? And how does it figure out the percentage?
by rpiboy
Fri Jun 19, 2020 7:58 pm
Forum: Python
Topic: Percentage with Numpy
Replies: 11
Views: 1031

Re: Percentage with Numpy

This is the NumPy array I have I want to know how is it calculating the percentage? I debug (more_calories) and I get True and False. import numpy as np cereal = [ 50, 50, 50, 70, 70, 80, 90, 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100...
by rpiboy
Fri Jun 19, 2020 7:52 pm
Forum: Python
Topic: Percentage with Numpy
Replies: 11
Views: 1031

Re: Percentage with Numpy

pidd wrote:
Fri Jun 19, 2020 7:47 pm
Don't you need something like ...

Code: Select all

more_calories = np.mean(cereal_array[cereal_array > 60])
That's not it.
by rpiboy
Fri Jun 19, 2020 7:22 pm
Forum: Python
Topic: Percentage with Numpy
Replies: 11
Views: 1031

Percentage with Numpy

This is the NumPy array I have I want to know how is it calculating the percentage? I debug (more_calories) and I get True and False. import numpy as np cereal = [ 50, 50, 50, 70, 70, 80, 90, 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,...
by rpiboy
Sun Apr 19, 2020 2:22 am
Forum: Python
Topic: Arbitrary argument help
Replies: 1
Views: 166

Arbitrary argument help

Hi, why does one code works and the other doesn't if it is doing the same thing? def build_profile(first, last, **user_info): """Build a dictionary containing everything we know about a user.""" user_info['first_name'] = first user_info['last_name'] = last return user_info user_profile = build_profi...
by rpiboy
Wed Jun 26, 2019 8:19 pm
Forum: Python
Topic: List Comprehension
Replies: 1
Views: 380

List Comprehension

colors = ["red", "orange", "yellow", "greeen", "blue"]

Code: Select all

colors2 = [item.upper() for item in colors]
What is the equivalent for loop code for that list comprehension?
by rpiboy
Tue Jun 11, 2019 6:51 pm
Forum: Python
Topic: How to print without newline
Replies: 7
Views: 1076

Re: How to print without newline

try raise TypeError("""The sentence should be of type str and not {}""".format(type(sentence))) and remove the unwanted white spaces, tabs and cr or lf from between the 2 text elements I know I can put it on one line and it'll print without a newline. I am wondering how I can get the code to print ...
by rpiboy
Tue Jun 11, 2019 6:05 pm
Forum: Python
Topic: How to print without newline
Replies: 7
Views: 1076

How to print without newline

raise TypeError("""The sentence should be of type str and not {}""".format(type(sentence))) That code prints on two different lines. How do I get it to print on the same line? TypeError: The sentence should be of type str and not <class 'int'>
by rpiboy
Fri Jun 07, 2019 6:39 pm
Forum: Python
Topic: Remove empty string in list
Replies: 5
Views: 538

Re: Remove empty string in list

You could put a while around the input along these lines: invite_person = [] yesorno = "" while yesorno not in ['yes', 'no']: yesorno = input("Do you want to invite a person? ") yesorno = yesorno.strip() yesorno = yesorno.lower() while yesorno == "yes": enter_invite = input(str("Enter invitee's nam...
by rpiboy
Fri Jun 07, 2019 4:08 am
Forum: Python
Topic: Remove empty string in list
Replies: 5
Views: 538

Remove empty string in list

invite_person = [] yesorno = input(str("Do you want to invite a person? ")) while yesorno == "yes": enter_invite = input(str("Enter invitee's name (or just enter to finish): ")) invite_person.append(enter_invite) yesorno = input(str("Do you want to invite more people? ")) for persons in invite_pers...
by rpiboy
Wed Apr 24, 2019 3:14 am
Forum: Python
Topic: Global and Local namespace
Replies: 1
Views: 282

Global and Local namespace

def scope_test(): def do_local(): spam = "local spam" def do_nonlocal(): nonlocal spam spam = "nonlocal spam" def do_global(): global spam spam = "global spam" spam = "test spam" do_local() print("After local assignment:", spam) do_nonlocal() print("After nonlocal assignment:", spam) do_global() pr...
by rpiboy
Sat Apr 20, 2019 2:28 am
Forum: Python
Topic: Event Timer
Replies: 1
Views: 268

Event Timer

import datetime import time class TimedEvent: def __init__(self, endtime, callback): self.endtime = endtime self.callback = callback def ready(self): return self.endtime <= datetime.datetime.now() class Timer: def __init__(self): self.events = [] def call_after(self, delay, callback): end_time = da...
by rpiboy
Mon Apr 15, 2019 9:43 pm
Forum: Python
Topic: Print a specific key, value for loop dictionary
Replies: 2
Views: 286

Print a specific key, value for loop dictionary

class Options: default_options = { 'port': 21, 'host': 'localhost', 'username': None, 'password': None, 'debug': False, } def __init__(self, **kwargs): self.options = dict(Options.default_options) self.options.update(kwargs) def __getitem__(self, key): return self.options[key] options = Options.def...
by rpiboy
Sun Apr 14, 2019 8:21 pm
Forum: Beginners
Topic: Help with NFC on the raspberry pi
Replies: 2
Views: 352

Re: Help with NFC on the raspberry pi

I believe the card is MIFARE classic 1k. I google it and it says that it's only a memory storage device what does that mean?
by rpiboy
Sun Apr 14, 2019 7:34 pm
Forum: Beginners
Topic: Help with NFC on the raspberry pi
Replies: 2
Views: 352

Help with NFC on the raspberry pi

I've bought an ACR122U and followed a tutorial on how to install it on the raspberry pi. I have also bought some NFC tags. I place the NFC tags on the ACR122U and I am seeing all the memory ADDR saying unknown. How come it doesn't say read and write? I want to write a hex number to address 5, 6 or a...
by rpiboy
Tue Apr 09, 2019 1:35 am
Forum: Python
Topic: Print and return
Replies: 2
Views: 496

Print and return

def get_pages(*links): for link in links: return(link) print(get_pages("Hello.com", "World.com")) How come I only get "Hello.com" as the output? Why it doesn't output "Hello.com" "World.com"? def get_pages(*links): for link in links: print(link) get_pages("Hello.com", "World.com") When I use print ...
by rpiboy
Mon Apr 08, 2019 4:34 am
Forum: Python
Topic: Empty list as a default argument
Replies: 1
Views: 585

Empty list as a default argument

I'm trying to understand this code. //DON'T DO THIS def hello(b=[]): b.append('a') print(b) hello() ['a'] hello() ['a', 'a'] Whoops, that's not quite what we expected! The usual way to get around this is to make the default value None, and then use the iargument = argument if argument else [] idiom ...
by rpiboy
Mon Apr 01, 2019 10:32 pm
Forum: Python
Topic: For Loop
Replies: 1
Views: 408

For Loop

I have this code that outputs two different results. I want to understand what's going on. normal_list = [1,2,3,4,5,6,7,8] class CustomSequence: def __len__(self): return 5 def __getitem__(self, index): return f"x{index}" class FunkyBackwards: def __reversed__(self): return "BACKWARDS!" for seq in C...

Go to advanced search