- Joined
- Dec 10, 2018
- Posts
- 86
- Reaction
- 33
- Points
- 103
Mema share muna.
Python basics muna.
Why python? ito kasi main PL ko.
Data types: list, dictionary, string, integer, float, conclusion, boolean, math func
List = []
Dictionary = {}
String = 'string'
Integer = 12345
Float = 1.2
Conclusion = print()
Boolean = true/flase
Functions = +,-,*,/
Dun sa tayo sa pinaka basic. Number guessing game. Simple program..code below.
Same lang kay word guessing game.
Ang pagkakaiba lang ay string ang nasa loob ng list at di na kelangan iconvert kasi string ang output ng input().
Next topic: 'while'
Python basics muna.
Why python? ito kasi main PL ko.
Data types: list, dictionary, string, integer, float, conclusion, boolean, math func
List = []
Dictionary = {}
String = 'string'
Integer = 12345
Float = 1.2
Conclusion = print()
Boolean = true/flase
Functions = +,-,*,/
Dun sa tayo sa pinaka basic. Number guessing game. Simple program..code below.
Code:
import random
#import natin yung module na random for access ng random functions
rand_this = [1, 2, 3, 4, 5, 6]
#integers in a list
guess = input('Guess a number from 1-6 \n')
#tatanungin kung anong hula mo.
#ang \n ay new line
result = random.choice(rand_this)
#pipili ang script ng choice dun sa list natin sa taas. RANDOMLY
if int(guess) == result:
print('You win!', guess, 'is', result)
else:
print('Sorry.', guess, 'is not', result)
#if and else statement. Yung nasa baba ay ang conclusions ang 'if' ay condition. Uri sya ng function.
#ang int() naman ay conversation from string. To integer.
Same lang kay word guessing game.
Ang pagkakaiba lang ay string ang nasa loob ng list at di na kelangan iconvert kasi string ang output ng input().
Next topic: 'while'