My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Thanks Tree1Thanks
  • 1 Post By Maschke
Reply
 
LinkBack Thread Tools Display Modes
December 23rd, 2018, 12:57 PM   #1
Newbie
 
Joined: Dec 2018
From: Fife WA

Posts: 6
Thanks: 0

Question Can you help me answer following python related questions?

In Python, what is returned when evaluating [n for n in range(10) if n % 2]?

In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2): return n1 + n2 my_func(1, 2, 3)

What is returned by datetime(1970, 1, 1).strftime('%Y-%d-%B') in Python?
Hellov is offline  
 
December 23rd, 2018, 01:45 PM   #2
Senior Member
 
Joined: Aug 2012

Posts: 2,214
Thanks: 656

Quote:
Originally Posted by Hellov View Post
In Python, what is returned when evaluating [n for n in range(10) if n % 2]?

In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2): return n1 + n2 my_func(1, 2, 3)

What is returned by datetime(1970, 1, 1).strftime('%Y-%d-%B') in Python?
What happens when you try out the examples in a Python program?
Maschke is offline  
December 23rd, 2018, 01:51 PM   #3
Newbie
 
Joined: Dec 2018
From: Fife WA

Posts: 6
Thanks: 0

Quote:
Originally Posted by Maschke View Post
What happens when you try out the examples in a Python program?
I dont have python program
Hellov is offline  
December 23rd, 2018, 01:54 PM   #4
Senior Member
 
Joined: Feb 2016
From: Australia

Posts: 1,770
Thanks: 627

Math Focus: Yet to find out.
Quote:
Originally Posted by Hellov View Post
I dont have python program
You're writing these posts on a computer aren't you? Try following this tutorial:

https://www.pythoncentral.io/execute...pt-file-shell/

edit: I've never used python before, but since submitting this post I was able to compile the above programs and look at what they output. Helps if you use a Linux machine but it's more or less trivial elsewhere. Programming is interactive, take advantage of that!

Last edited by Joppy; December 23rd, 2018 at 02:01 PM.
Joppy is offline  
December 23rd, 2018, 02:10 PM   #5
Senior Member
 
Joined: Aug 2012

Posts: 2,214
Thanks: 656

Quote:
Originally Posted by Hellov View Post
I dont have python program
Try this.

https://www.onlinegdb.com/online_python_interpreter

A Google search for "online python" brought up many such sites.
Thanks from Joppy
Maschke is offline  
December 23rd, 2018, 10:34 PM   #6
Newbie
 
Joined: Dec 2018
From: Amsterdam

Posts: 26
Thanks: 2

You code is incomplete but here are the answers:

First one is SyntaxError: invalid syntax
Second one: my_func() takes 2 positional arguments but 3 were given
Third one: NameError: name 'datetime' is not defined
jenniferruurs is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
answer, python, questions, related



Search tags for this page
Click on a term to search for related topics.
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some questions related to variables and operations Integraluser Algebra 4 August 15th, 2018 01:39 AM
Two questions related to normal distribution wajeeha yasin Probability and Statistics 1 December 31st, 2016 12:49 PM
Area related questions Drunkuncito Calculus 4 June 23rd, 2016 03:59 PM
Two very basic questions related to time series analysis sydfremmer Advanced Statistics 1 December 17th, 2012 12:27 PM
please dont post questions not related to algebra kaulabhishek_862 Abstract Algebra 1 June 25th, 2008 07:03 AM





Copyright © 2019 My Math Forum. All rights reserved.