Uploaded by Gavin Patrick

Лабораторијска вежба из програмирања

advertisement
Revised Lab-8
Gavin McAllister.
Professor Thomas, Craver.
11/06/2023
1. times_ten:
def times_ten(input):
input_multiplied = input * 10
print(f’Your input multiplied by ten is equal to {input_multiplied}’)
2. Header Problem:
def main():
input_quantity = 12
show_value(input_quantity)
def show_value(quantity):
print(f'The quantity is {quantity}')
main()
3. Value a?
The value a will be assigned to 3, b assigned to 2, and c assigned to 1.
4.
The code will print the following:
1 3.4
00
1 3.4
5. Keyword Argument:
def main():
value_1 = 2
value_2 = 4
value_3 = 6
my_function(value_1, value_2, value_3
6. Random Number Generator:
import random
MIN = 1
MAX = 100
def main():
print(random.randint(MIN, MAX))
main()
7. Half Code
def half(a):
half_input = a/2
print(f'Your value is {half_input}')
def main():
user_input = int(input('Please input a value you wish to half: '))
half(user_input)
main()
8. Cube Program
def cube(num):
return num * num * num
result = cube(4)
print(result)
9. Times Ten
def times_ten(num):
return num * 10
def main():
result = times_ten(5)
print(result) # This will output: 50
main()
10. Get name Function:
def get_first_name():
name = input("Please enter your name: ")
return name
def main():
first_name = get_first_name()
print(f'Your first name is {first_name}')
main()
Download