Questions tagged [built-in]

Built-in functions, modules and classes are standard parts of a programming language or framework.

Built-in functions, modules and classes are standard parts of a programming language or framework.

Generally, all parts of a programming language or framework that don't require the installation of additional components are considered built-in.

1177 questions
-2
votes
3 answers

dictionary of built in methods in python

I'm trying to create a dictionary of built in methods but I'm getting the output as shown in below. Why is this happening? I just want to understand that. >>> >>> dict = {'a': print('avc'), 'b': print('bbbb'), 'c': print('aaa')} avc bbbb aaa >>>…
Gourav Chawla
  • 470
  • 1
  • 4
  • 12
-2
votes
1 answer

Single function for asking and reading input in C#

I am looking for the built-in equivalent of this function: public static string ask(string prompt) { Console.Write(prompt); return Console.ReadLine(); } I think it is tedious to copy-paste this in every console app, and creating a new class…
Caridorc
  • 6,222
  • 2
  • 31
  • 46
-2
votes
1 answer

.equals() method in Java objects

I´m having some trouble understanding this code. I know I need to create a method to compare non built-ins, but could someone please explain to me, in detail what the boolean equals() is actually doing? public class Book { private String…
Pafmac289
  • 13
  • 3
-2
votes
2 answers

In Python, what's the best way to get an unknown int from a string?

SOLUTION: Ok guys I ended up using the following. It involves regular expressions. This is what I was trying to get at. matches = re.findall(r'My favorite chili was number \d+"', line) # gets 1 match if matches: # if there are matches …
user3745189
  • 521
  • 1
  • 7
  • 17
-2
votes
1 answer

Python built-in id() not consistent:

Hoping someone can explain the following discrepancy: >>> s1 = "Cyber security" >>> s2 = "Cyber security" >>> id(s1) == id(s1) True >>> id(s1) == id(s2) False >>> s1 = "cyber" >>> s2 = "cyber" >>> id(s1) == id(s2) True >>> s2 = "cyber " >>> s2 =…
Dannellyz
  • 31
  • 2
-3
votes
2 answers

Know what is happening inside functios or methods

I've been working with Python for a while, but now I got curious if there is a way to see the code inside the built-in functions or methods of Python. I know that is not really necessary to know this, but some time I'm a curious person. Thanks for…
AskMeee12
  • 1
  • 1
-3
votes
3 answers

add more than two objects with __add__ function

I have a class it can successfully add two variables of object of class a class a(): def __add__(self, other): return self.val+other.val def __init__(self,a): self.val=a aa=a(22) bb=a(11) aa+bb 33 But when I try to give it…
Artier
  • 1,648
  • 2
  • 8
  • 22
-3
votes
1 answer

What do the qualifiers [0][1] do?

Please consider the following code which compiles and runs import numpy as np tgt = np.array([3,5,8,10,12,15]) num_guesses = 10 results =[] for g in range(num_guesses): guess = np.random.uniform(low = tgt.min(), high = tgt.max()) …
David
  • 95
  • 9
-3
votes
1 answer

Spyder console not displaying function output

I'm new to coding, and as I was going through a beginner's Python walkthrough, I found that the console in Spyder won't give an output that states the class type of the argument. Image after running type () in Spyder:
woojaee
  • 21
  • 3
-3
votes
1 answer

What part of this code is not iteratable?

I get the "main loop 'builtin_function_or_method' object is not iterable" error when I run the code below. The error occurs in for word_search in search_list: I can't figure out what the built-in function or method is. end_search=[] #Remove…
-3
votes
1 answer

Does everything come down to builtin objects in Python?

There are functions such as print that are embedded in CPython and there are other functions such as os.makedirs that are written in external .py files (i.e. in os.py). As far as I know, print() would call some C code that is already written inside…
Andrew
  • 1
  • 1
-3
votes
1 answer

Is the function in namespace code running into infinite loop or what?

I'm using PHP 7.2.1 Consider below code :
user9059272
-3
votes
2 answers

Comparing and reducing difference between two numbers regardless of which is larger

I'm using the abs built-in function to measure the difference between two numbers regardless of whether x is bigger than y or vice versa. For example, if y = 5 and x = 7, the result will be 2. If y = 7 and x = 5, result will still be 2. But if I…
SamChancer
  • 75
  • 5
-3
votes
1 answer

Alter the content of a float instance?

I would like to modify the value of a float instance as follow: >>>%paste class MyFloat(float): def foo(self): self = self + 1 >>> f = MyFloat(41) >>> f.foo() >>> f 41.0 Unfortunately self += 1 does not work I assume the builtins objects…
nowox
  • 25,978
  • 39
  • 143
  • 293
-3
votes
1 answer

Using eval to perform a mathematical operation

In the code below the line of code prod = eval("beg1" "operation" "beg2") doesn't work! If anyone could give me some help I would gratefully appreciate it! def quiz(): global tally tally = 0 questions = 10 name = input("What is…
David
  • 3
  • 1
1 2 3
78
79