Python - Can't reproduce console output in a file form - python-3.5

I'm very new to Python, with no previous experience in programming, so if my questions seem stupid, that's because they are.
I was trying to lean a bit more about the "requests" library, so I installed it and followed the instructions in this page (http://docs.python-requests.org/en/master/user/quickstart/). When I got to "Response Content", I tried to emulate the code by copying and pasting it, creating a file named pedidos.py, and running it on my terminal. But when I run it, nothing happens.
This is the code as I copied it:
import requests
r = requests.get('https://api.github.com/events')
r.text
The strangest thing is, if I open a python console in my terminal and input this code line by line, I get a output, which doesn't happen if run it through the file.
I'm fairly certain that the answer to my question is, probably, very simple, and that I will be ashamed to have asked it once someone explains it to me. But the truth is that I'm stuck and really need some help.
Thanks in advance to anyone who takes the time to answer.

Related

Is it possible to run a python script when another computer connects to the website?

Im trying to set up a prank for my coder friends(have to clarify its not something bad, its just a harmless joke) and they are much more experienced than me. They like to brag about it, so I wanted to make them look like they got hacked by getting a singular file from their computer. Is it possible to run a script to take a their file from their computer as soon as they click on a link that i can share on discord?
I got python script to get a file, but its only when you download the script and use it, it also requires you to have any python version 3+ to run the code. Tried to make a short link but couldnt get it work either.

I'm trying to use the turtle methods, etc. listed on the official python page but I keep getting errors

I'm using turtle to create a video game.
I'm making this program for a virtual class, and I don't know the exact limitations of the (online) IDLE provided. I'm not currently able to test my code in any other environment. I don't want to use pygame or anything because I don't know if I can and also I don't want to rewrite a bunch of my code.
The problems I'm having are mostly with the TurtleScreen/Screen. I can't call .Screen() or .TurtleScreen(), .bgcolor(), .turtlesize(), and probably a lot more I haven't checked yet. Here's an example:
bg = turtle.Screen()
turt = turtle.Turtle()
bg.bgcolor("black")
I just receive a
ParseError: bad input
when I run it. Any input is much appreciated!
A parse error usually comes from python being unable to parse your code rather than an issue with Turtle.
The code snippet you posted above works fine so the problem is likely with some other lines of code that precede it. Double check your syntax on lines before the error occurs and make sure there aren't any missing parenthesis, brackets, quotes, etc that would impact later lines.

Create a program that asks the user for a string and then prints the string in upper case

EDIT: I tried the code lines in the link to other questions that were similar, however the programs did not execute correctly
I am a full-on noob trying to complete some free online resources for self improvement and learning. I am using University of Waterloo's 'Python from scratch' and CS circles course I have tried to answer this question and cannot seem to:
Write a program that asks the user for a string and then prints the string in upper case.
I have tried:
print (str(input()).upper)
AS WELL AS
text = input()
print (text.upper)
AND
print(input().upper())
all programs run, but dont have correct output so I dont know what I am missing here. It's likely obvious and I may feel foolish
I would love to learn and move on, thanks for any assistance!
this is 'Python from scratch' 2.11 problem 'g' (7th problem in set)
You were very close, the following works:
input.upper()
so, print(input.upper())
should work for you.
text=input()
print(text.upper())
print(input().upper())
This should have worked for you in Python 3.x

Excel can't establish with xlwings connection when running from standalone Python app from Excel

I am trying to create standalone app from a script with xlwings. I used both py2exe and cx_freeze. Both work just fine outside Excel (I added some tests). When I import either of them as a VBA macros in Excel, they also work fine. But so far, on my computer only. I asked my friend to check if the script works on her computer and she got the following error:
So I thought it make sense to figure out whether I do something wrong. I sent her a Fibonacci example and it raised sort of the same error:
It should be something wrong with names of the files, but it's not like obvious for me what exactly. Maybe somebody already knows how to deal with it? Thanks!
If files are downloaded from the internet, they only work right away in the first instance of Excel. Meaning: Your friend should try to close Excel completely. Also check in the Task Manager if there is still an EXCEL process running and if so, kill it. Then try again in a fresh instance of Excel.
update:
Ah I see - the problem seems to be a bug happening when there are unicode characters involved in the file path! I've opened a issue here. In the meantime, try to run the file on a path without unicode characters.

Matlab UI program works unproperly after deploytool

this is the first time I'm encountering this kind of issue.
I have a perfectly working code that runs without any issue under 3 different platforms (Win/Linux/OS X).
However after the deploytool compilation a part of it stops working. How can I get the error once the code is compiled!? It seems that it has some problems in loading and reading .mat files. Is that possible?
I hope someone can help me.
Thanks
edit:
I've solved the problem! Unfortunately was all addpath fault!
I have a lot of folders with files and functions that are needed for running the code, after the compilation matlab does a mess with all of that folders.
Good hint: do not use addpath for the compilation! Thank you anyway!
You can try to catch the error and write it to a text file. Or build in a check that prints text to the screen.
A bit more in general: You can try to isolate the part of the code that has the problem, and then basically cut out half of the functionality in this part repeatedly until you have exactly found the source of the error.

Resources