Informatika2-2020/Gyak01
a |
a (→Python futtatása) |
||
3. sor: | 3. sor: | ||
== Jupyterhub == | == Jupyterhub == | ||
− | * | + | * Jelentkezzetek be a [https://jupyter.math.bme.hu:8888 jupyter.math.bme.hu]-ra a '''<tt>leibniz</tt>-es felhasználónévvel és jelszóval''' |
− | * | + | * '''Python 3'''-at fogunk használni! |
− | * | + | * Ez a notebook hasonlít ahhoz, mint amikor saját gépről ezt futtatod: |
jupyter notebook | jupyter notebook | ||
== leibniz == | == leibniz == | ||
− | * | + | * A konzol-ba ezt írjuk be: |
python3 | python3 | ||
+ | |||
+ | * kilépni az így lehet: | ||
+ | |||
+ | exit() | ||
== Own machine == | == Own machine == |
A lap 2020. február 12., 12:34-kori változata
Tartalomjegyzék |
Python futtatása
Jupyterhub
- Jelentkezzetek be a jupyter.math.bme.hu-ra a leibniz-es felhasználónévvel és jelszóval
- Python 3-at fogunk használni!
- Ez a notebook hasonlít ahhoz, mint amikor saját gépről ezt futtatod:
jupyter notebook
leibniz
- A konzol-ba ezt írjuk be:
python3
- kilépni az így lehet:
exit()
Own machine
Install Anaconda, version 3.7 is needed!
- how to install Anaconda on windows
- You can use other distributions such as
Having Anaconda you can run several programs to interact with python:
- command line: python or ipython
- Spyder
- idle
- jupyter notebook
Exercises
Introduction
- Try the notebook from the lecture.
- download from wiki and upload it into jupyter.math.bme.hu
- Try a welcoming program (from terminal)!
- Try division (integer and float)
tocelsius
Write a python function that convets from Fahrenheit to Celsius
The function should
- be called tocelsius
- have one parameter (called fahrenheit)
- return the appropriate Fahrenheit degrees as float.
- To get the Celsius, subtract 32 from the Fahrenheit value then multipy with 5 / 9.
- See examples here
isaprime
Write a function that tells whether a number is a prime or not!
The function should be called isaprime and have one parameter:
- x, the number in question
The function should return True
or False
depending on the number.
For safety reasons, you can check the type and value of the input. Accept only positive integers!
If you get a non-integer or a non-positive integer, return None
roomtemp
According to <a href="https://en.wikipedia.org/wiki/Room_temperature">Wikipedia</a> a room has a temperature between 18°C and 25°C. Write a function that decides that for us.
The function should
- be called roomtemp
- have one parameter: degree the temperature of the room in Celsius degrees.
- return either one of the following strings depending on the temperature:
-
"Too cold!"
-
"Too hot!"
-
"OK"
-
Mind that there is a difference between print
and return
factorial
Write a function which calculates n factorial
factorial
Write a function which calculates n factorial
without 2
You should divide a positive integer n with a power of two, until it is not divisible by 2.
Call the function withouttwo
with one parameter:
- n, a positive integer
- Return the number divided by the greatest possible power of two.
For example
1 -> 1 2 -> 1 3 -> 3 4 -> 1 6 -> 3 7 -> 7 9 -> 9 10 -> 5 100 -> 25