Personal tools
You are here: o studio 110 anno anno AKT py pass s 24-27.py

Die einzige Konstante im Universum ist die Veränderung.

Heraklit von Ephesus

When you need a function, just declare it.

 

Ego ist eine Illusion.

Marco Asam

Life is like a camera -
focus on what's important
capture the good times,
develop from the negatives
and if things don't work out
take another shot.

Anonymous

 

 

 

 

 

 

 

 

 

py pass s 24-27.py

py pass s 24-27.py — Python Source, 2Kb

File contents

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> for num in range (2,10)
SyntaxError: invalid syntax
>>> for num in range (2,10):
	if num % 2 == 0:
		print ("Found an even number" , num)
		continue
	print ("Found a number" , num)

	
Found an even number 2
Found a number 3
Found an even number 4
Found a number 5
Found an even number 6
Found a number 7
Found an even number 8
Found a number 9
>>> while True:
	pass 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> 
KeyboardInterrupt
>>> class MyEmptyClass:
	pass
KeyboardInterrupt
>>> def fib(n):
	"""Print the Fibonacci series up to n"""
	a, b = 0, 1
	while a < n
	
SyntaxError: invalid syntax
>>> while a < n:
	print (a, end=` ´)
	
SyntaxError: invalid syntax
>>> print (a, end=´ ´)
SyntaxError: invalid character in identifier
>>> print (a, end=' ')
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    print (a, end=' ')
NameError: name 'a' is not defined
>>> print()

>>> 
>>> 
>>> 
>>> 
>>> fib(2000)
Traceback (most recent call last):
  File "<pyshell#27>", line 1, in <module>
    fib(2000)
NameError: name 'fib' is not defined
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> fib(0)
Traceback (most recent call last):
  File "<pyshell#38>", line 1, in <module>
    fib(0)
NameError: name 'fib' is not defined
>>> print (fib(0))+
SyntaxError: invalid syntax
>>> print (fib(0))
Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    print (fib(0))
NameError: name 'fib' is not defined
>>> def fib2 (n):
	result = list()
	a, b =0, 1
	while a < n
	
SyntaxError: invalid syntax
>>> def fib2 (n):
	result = list()
	a, b =0, 1
	while a < n:
		result. append (a)
		a, b = b, a + b
		return result
	f100 = fib2 (100)
	f100
	[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

	
>>> 
>>> 
>>> 
>>> def ask_ok (promt, retries=4, complaint= 'Bitte Ja oder Nein!'):
	while True:
		ok=input( promt)
		if ok in ('j', 'J', 'ja', 'Ja',): return True
		if ok in ('n', 'N', 'ne', 'Ne', 'Nein'): return False
		retries = retries - 1
		if retries < 0:

		Ne
		
SyntaxError: expected an indented block
>>> n
Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    n
NameError: name 'n' is not defined
>>> Ja
Traceback (most recent call last):
  File "<pyshell#66>", line 1, in <module>
    Ja
NameError: name 'Ja' is not defined
>>> 'Ja'
'Ja'
>>> 'Hallo'
'Hallo'
>>> 
>>> #+
SyntaxError: invalid syntax
>>> 
>>> 
>>> 
>>> 
>>> 
Document Actions