Write a program that asks the user for their name and greets them. <br>
> Use the Function ``input("text for user")`` to give a user input to a variable
%% Cell type:code id:a16c6da4 tags:
``` python
```
%% Output
Hello, haniball!
%% Cell type:markdown id:4cd048de tags:
### 1.2 type casting
Create variables with basic data types with the following names, which can store the corresponding value:
| Name | Value |
| ---- | ------------- |
| a | 30492 |
| b | 'X' |
| c | 87.432 |
| d | "Hello World" |
| e | True |
%% Cell type:code id:cb7b2da4 tags:
``` python
```
%% Cell type:markdown id:72ea9ad1 tags:
Run the following script to test if your solution is correct
%% Cell type:code id:28745df1 tags:
``` python
def check_types(a, b, c, d, e):
if isinstance(a, int) and isinstance(b, str) and isinstance(c, float) and isinstance(d, str) and isinstance(e, bool):
return "Your result is correct"
else:
return "There is an error"
result = check_types(a, b, c, d, e)
print(result)
```
%% Output
Your result is correct
%% Cell type:markdown id:cb931520 tags:
### 1.3 comparing variables
Write a program that compares whether a is greater than b and prints ``True`` or ``False``
%% Cell type:code id:d0f961d8 tags:
``` python
a = 2
b = 6
print(a > b)
```
%% Output
False
%% Cell type:markdown id:be4e3737 tags:
### 2 Control structures
%% Cell type:markdown id:a0122eba tags:
### 2.1 if and else statements
%% Cell type:markdown id:e9e1fa12 tags:
#### 2.1.1 even number
Write a program that checks a number and outputs whether it is even or odd.
%% Cell type:code id:73e37cc2 tags:
``` python
number = 4
```
%% Cell type:code id:273fc6d1 tags:
``` python
```
%% Output
Die Zahl ist gerade.
%% Cell type:markdown id:e2fc0c01 tags:
## 2.1.2 Simple Conditional
Write a program that checks a number from a user input to see whether it is positive, negative or zero.
%% Cell type:code id:811d885d tags:
``` python
```
%% Output
The number is positive
%% Cell type:markdown id:eb66c676 tags:
#### 2.1.3 User roles
Write a program that checks the role of a user and issues the corresponding authorizations.<br><br>
**Admin** has all authorizations <br>
**Editor** can edit content <br>
**User** can view content <br>
%% Cell type:code id:4ad521c7 tags:
``` python
role =input("what's your role")
```
%% Cell type:code id:d54646c1 tags:
``` python
```
%% Output
can view content
%% Cell type:markdown id:d79ce120 tags:
#### 2.1.4 Leap year check
Write a program that checks whether a year is a leap year. A year is a leap year if it is dividable by 4, but not by 100, unless it is also dividable by 400.